fix: `expect _ = ...` not including the cast from data logic if the type is data and right hand has a type annotation
This commit is contained in:
parent
226556bdd6
commit
8b3504e9a1
|
@ -15,6 +15,7 @@
|
|||
|
||||
### Fixed
|
||||
|
||||
- **aiken-lang**: Fix expect _ = ... not including the cast from data logic if the type is data and right hand has a type annotation
|
||||
- **aiken-lang**: Fix for the final clause of a when expecting another clause
|
||||
afterwards in nested list cases.
|
||||
- **aiken-lang**: Fix for all elements were being destructured in tuple clauses
|
||||
|
@ -22,7 +23,8 @@
|
|||
- **aiken-lang**: Fix for tuple clause not consuming the next case causing
|
||||
incomplete contracts. Now tuple clause will always consume the next case
|
||||
unless it is the final clause
|
||||
- **aiken-lang**: Fix for builtins using the incorrect data to type conversion when used as a function param.
|
||||
- **aiken-lang**: Fix for builtins using the incorrect data to type conversion
|
||||
when used as a function param.
|
||||
|
||||
## v1.0.10-alpha - 2023-06-13
|
||||
|
||||
|
|
|
@ -1701,7 +1701,7 @@ impl<'a> CodeGenerator<'a> {
|
|||
) {
|
||||
let mut value_stack = if assignment_properties.value_type.is_data()
|
||||
&& !tipo.is_data()
|
||||
&& !pattern.is_discard()
|
||||
&& matches!(assignment_properties.kind, AssignmentKind::Expect)
|
||||
{
|
||||
let mut wrap_stack = pattern_stack.empty_with_scope();
|
||||
wrap_stack.un_wrap_data(tipo.clone().into());
|
||||
|
@ -1765,7 +1765,17 @@ impl<'a> CodeGenerator<'a> {
|
|||
);
|
||||
}
|
||||
Pattern::Discard { .. } => {
|
||||
pattern_stack.let_assignment("_", value_stack);
|
||||
if matches!(assignment_properties.kind, AssignmentKind::Let) {
|
||||
pattern_stack.let_assignment("_", value_stack);
|
||||
} else {
|
||||
self.expect_pattern(
|
||||
pattern,
|
||||
pattern_stack,
|
||||
value_stack,
|
||||
tipo,
|
||||
assignment_properties,
|
||||
)
|
||||
}
|
||||
}
|
||||
list @ Pattern::List { .. } => {
|
||||
if matches!(assignment_properties.kind, AssignmentKind::Expect)
|
||||
|
@ -2097,7 +2107,12 @@ impl<'a> CodeGenerator<'a> {
|
|||
self.expect_type(tipo, expect_stack, name, &mut IndexMap::new());
|
||||
}
|
||||
Pattern::Assign { .. } => todo!("Expect Assign not supported yet"),
|
||||
Pattern::Discard { .. } => unreachable!(),
|
||||
Pattern::Discard { .. } => {
|
||||
let name = "__expect_discard";
|
||||
|
||||
expect_stack.let_assignment(name, value_stack);
|
||||
self.expect_type(tipo, expect_stack, name, &mut IndexMap::new());
|
||||
}
|
||||
Pattern::List { elements, tail, .. } => {
|
||||
let inner_list_type = &tipo.get_inner_types()[0];
|
||||
let mut names = vec![];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name = "aiken-lang/acceptance_test_083"
|
||||
name = "aiken-lang/acceptance_test_084"
|
||||
version = "0.0.0"
|
||||
description = ""
|
||||
|
||||
|
|
|
@ -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_085"
|
||||
version = "0.0.0"
|
||||
description = ""
|
||||
|
||||
[[dependencies]]
|
||||
name = 'aiken-lang/stdlib'
|
||||
version = 'main'
|
||||
source = 'github'
|
|
@ -0,0 +1,19 @@
|
|||
pub type AssetClass {
|
||||
policy: ByteArray,
|
||||
name: ByteArray,
|
||||
}
|
||||
|
||||
pub type DatumOrc {
|
||||
oracle_parameters: OracleParametersd,
|
||||
token_a_amount: Int,
|
||||
token_b_amount: Int,
|
||||
expiration_time: Int,
|
||||
maturity_time: Int,
|
||||
}
|
||||
|
||||
pub type OracleParametersd {
|
||||
pool_nft_cs: AssetClass,
|
||||
oracle_nft_cs: AssetClass,
|
||||
token_a_cs: AssetClass,
|
||||
token_b_cs: AssetClass,
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
use other
|
||||
|
||||
pub type AssetClass {
|
||||
policy: ByteArray,
|
||||
name: ByteArray,
|
||||
}
|
||||
|
||||
pub type DatumOrc1 {
|
||||
oracle_parameters: OracleParametersd,
|
||||
token_a_amount: Int,
|
||||
token_b_amount: Int,
|
||||
expiration_time: Int,
|
||||
maturity_time: Int,
|
||||
}
|
||||
|
||||
pub type OracleParametersd {
|
||||
pool_nft_cs: AssetClass,
|
||||
oracle_nft_cs: AssetClass,
|
||||
token_a_cs: AssetClass,
|
||||
token_b_cs: AssetClass,
|
||||
}
|
||||
|
||||
test oracle1() {
|
||||
let x: Data =
|
||||
DatumOrc1 {
|
||||
oracle_parameters: OracleParametersd {
|
||||
pool_nft_cs: AssetClass { policy: #"", name: #"" },
|
||||
oracle_nft_cs: AssetClass { policy: #"", name: #"" },
|
||||
token_a_cs: AssetClass { policy: #"", name: #"" },
|
||||
token_b_cs: AssetClass { policy: #"", name: #"" },
|
||||
},
|
||||
token_a_amount: 0,
|
||||
token_b_amount: 0,
|
||||
expiration_time: 0,
|
||||
maturity_time: 0,
|
||||
}
|
||||
|
||||
let y: Data = x
|
||||
|
||||
expect _: other.DatumOrc = y
|
||||
|
||||
// od == od
|
||||
True
|
||||
}
|
Loading…
Reference in New Issue