test: add acceptance test 86
fix: prevent mutual recursion for expect type code gen functions
This commit is contained in:
parent
841547dd6c
commit
67c072a1a9
|
@ -6,6 +6,10 @@
|
|||
|
||||
- **aiken**: added a `blueprint policy` command to compute the policy ID of a minting script
|
||||
|
||||
### Fixed
|
||||
|
||||
- **aiken-lang**: Prevent mutual recursion caused by conflicting function names for generic expect type
|
||||
|
||||
### Changed
|
||||
|
||||
### Removed
|
||||
|
|
|
@ -19,7 +19,7 @@ use crate::{
|
|||
builtins::{bool, data, void},
|
||||
expr::TypedExpr,
|
||||
gen_uplc::builder::{
|
||||
find_and_replace_generics, get_generic_id_and_type, get_variant_name,
|
||||
find_and_replace_generics, get_arg_type_name, get_generic_id_and_type, get_variant_name,
|
||||
lookup_data_type_by_tipo,
|
||||
},
|
||||
tipo::{
|
||||
|
@ -2533,7 +2533,11 @@ impl<'a> CodeGenerator<'a> {
|
|||
let mut func_stack = expect_stack.empty_with_scope();
|
||||
let mut call_stack = expect_stack.empty_with_scope();
|
||||
|
||||
let mut data_type_variant = String::new();
|
||||
let mut data_type_variant = tipo
|
||||
.get_inner_types()
|
||||
.iter()
|
||||
.map(|arg| get_arg_type_name(arg))
|
||||
.join("_");
|
||||
|
||||
if let Some(types) = tipo.arg_types() {
|
||||
for mut tipo in types {
|
||||
|
|
|
@ -2029,3 +2029,15 @@ pub fn special_case_builtin(
|
|||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_arg_type_name(tipo: &Type) -> String {
|
||||
match tipo {
|
||||
Type::App { name, .. } => name.clone(),
|
||||
Type::Var { tipo } => match tipo.borrow().clone() {
|
||||
TypeVar::Link { tipo } => get_arg_type_name(tipo.as_ref()),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
Type::Tuple { .. } => "".to_string(),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# This file was generated by Aiken
|
||||
# You typically do not need to edit this file
|
||||
|
||||
[[requirements]]
|
||||
name = "aiken-lang/stdlib"
|
||||
version = "main"
|
||||
source = "github"
|
||||
|
||||
[[packages]]
|
||||
name = "aiken-lang/stdlib"
|
||||
version = "main"
|
||||
requirements = []
|
||||
source = "github"
|
|
@ -0,0 +1,8 @@
|
|||
name = "aiken-lang/acceptance_test_086"
|
||||
version = "0.0.0"
|
||||
description = ""
|
||||
|
||||
[[dependencies]]
|
||||
name = 'aiken-lang/stdlib'
|
||||
version = 'main'
|
||||
source = 'github'
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"preamble": {
|
||||
"title": "aiken-lang/acceptance_test_086",
|
||||
"version": "0.0.0",
|
||||
"plutusVersion": "v2"
|
||||
},
|
||||
"validators": [
|
||||
{
|
||||
"title": "other.validate",
|
||||
"datum": {
|
||||
"title": "raw_datum",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Data"
|
||||
}
|
||||
},
|
||||
"redeemer": {
|
||||
"title": "_redeemer",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Data"
|
||||
}
|
||||
},
|
||||
"compiledCode": "5901fd01000032323232323232323232222533300832323232533300c3370e9000000899251300a00214a06014002601c002600e008664464a66601666e1d20000011323253330103012002132498c94ccc038cdc3a400000226464a666026602a0042649319299980899b87480000044c8c94ccc058c0600084c9263253330143370e9000000899191919299980d980e8010991924c64a66603466e1d200000113232533301f3021002132498c94ccc074cdc3a400000226464a666044604800426493180b8008b1811000980d8010a99980e99b87480080044c8c8c8c8c8c94ccc098c0a000852616375a604c002604c0046eb4c090004c090008dd69811000980d8010b180d8008b180f800980c0018a99980d19b874800800454ccc074c06000c52616163018002301000316301b001301b00230190013012002163012001163016001300f00216300f001163013001300c0021533300e3370e90010008a99980898060010a4c2c2c60180022c602000260120042c6012002464a66601466e1d200000113232533300f3011002149858dd7180780098040010a99980519b87480080044c8c94ccc03cc04400852616375c601e00260100042c60100020062930b19800800a40004444666600e66e1c00400c02c8cccc014014cdc000224004601a0020040044600a6ea80048c00cdd5000ab9a5573aaae7955cfaba15745",
|
||||
"hash": "6a76fed919611638154fbaf78bd7a37f98b77e42eebc615f2d2d0f32"
|
||||
}
|
||||
],
|
||||
"definitions": {
|
||||
"Data": {
|
||||
"title": "Data",
|
||||
"description": "Any Plutus data."
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
use aiken/transaction.{ScriptContext}
|
||||
use aiken/transaction/credential.{Address}
|
||||
|
||||
type TestData {
|
||||
addr: Address,
|
||||
}
|
||||
|
||||
type TestDatum {
|
||||
data: Option<TestData>,
|
||||
}
|
||||
|
||||
validator {
|
||||
fn validate(raw_datum: Data, _redeemer: Data, _context: ScriptContext) -> Bool {
|
||||
expect datum: TestDatum = raw_datum
|
||||
let TestDatum { data } = datum
|
||||
when data is {
|
||||
Some(_) -> True
|
||||
None -> False
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue