Fix: Get the type of Chain.create() from its application (#407)
* Get the type of Chain.create() from its application * Add test contract * Update CHANGELOG.md * Update the tests * Update tests again
This commit is contained in:
parent
4dbc9858fb
commit
c98ea25e8b
@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
### Changed
|
### Changed
|
||||||
### Removed
|
### Removed
|
||||||
|
### Fixed
|
||||||
|
- [404](https://github.com/aeternity/aesophia/issues/404) Contract polymorphism crashes on non-obvious child contract typing.
|
||||||
|
|
||||||
## [7.0.0]
|
## [7.0.0]
|
||||||
### Added
|
### Added
|
||||||
|
@ -693,7 +693,7 @@ expr_to_fcode(Env, _Type, {app, _Ann, {Op, _}, [A]}) when is_atom(Op) ->
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
%% Function calls
|
%% Function calls
|
||||||
expr_to_fcode(Env, Type, {app, _, Fun = {typed, _, FunE, {fun_t, _, NamedArgsT, ArgsT, _}}, Args}) ->
|
expr_to_fcode(Env, _, {app, _, Fun = {typed, _, FunE, {fun_t, _, NamedArgsT, ArgsT, Type}}, Args}) ->
|
||||||
Args1 = get_named_args(NamedArgsT, Args),
|
Args1 = get_named_args(NamedArgsT, Args),
|
||||||
FArgs = [expr_to_fcode(Env, Arg) || Arg <- Args1],
|
FArgs = [expr_to_fcode(Env, Arg) || Arg <- Args1],
|
||||||
case expr_to_fcode(Env, Fun) of
|
case expr_to_fcode(Env, Fun) of
|
||||||
|
@ -202,6 +202,7 @@ compilable_contracts() ->
|
|||||||
"polymorphism_contract_interface_extensions",
|
"polymorphism_contract_interface_extensions",
|
||||||
"polymorphism_contract_interface_same_decl_multi_interface",
|
"polymorphism_contract_interface_same_decl_multi_interface",
|
||||||
"polymorphism_contract_interface_same_name_same_type",
|
"polymorphism_contract_interface_same_name_same_type",
|
||||||
|
"polymorphism_variance_switching_chain_create",
|
||||||
"missing_init_fun_state_unit",
|
"missing_init_fun_state_unit",
|
||||||
"complex_compare_leq",
|
"complex_compare_leq",
|
||||||
"complex_compare",
|
"complex_compare",
|
||||||
@ -1025,6 +1026,20 @@ failing_contracts() ->
|
|||||||
"Cannot unify `Animal` and `Cat` in a covariant context\n"
|
"Cannot unify `Animal` and `Cat` in a covariant context\n"
|
||||||
"when checking the type of the pattern `q15 : oracle_query(Cat, Cat)` against the expected type `oracle_query(Cat, Animal)`">>
|
"when checking the type of the pattern `q15 : oracle_query(Cat, Cat)` against the expected type `oracle_query(Cat, Animal)`">>
|
||||||
])
|
])
|
||||||
|
, ?TYPE_ERROR(polymorphism_variance_switching_chain_create_fail,
|
||||||
|
[<<?Pos(9,22)
|
||||||
|
"I is not implemented.\n"
|
||||||
|
"when resolving arguments of variadic function `Chain.create`">>,
|
||||||
|
<<?Pos(10,13)
|
||||||
|
"Cannot unify `I` and `C` in a covariant context\n"
|
||||||
|
"when checking the type of the pattern `c2 : C` against the expected type `I`">>,
|
||||||
|
<<?Pos(10,22)
|
||||||
|
"I is not implemented.\n"
|
||||||
|
"when resolving arguments of variadic function `Chain.create`">>,
|
||||||
|
<<?Pos(11,22)
|
||||||
|
"I is not implemented.\n"
|
||||||
|
"when resolving arguments of variadic function `Chain.create`">>
|
||||||
|
])
|
||||||
, ?TYPE_ERROR(missing_definition,
|
, ?TYPE_ERROR(missing_definition,
|
||||||
[<<?Pos(2,14)
|
[<<?Pos(2,14)
|
||||||
"Missing definition of function `foo`">>
|
"Missing definition of function `foo`">>
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
contract interface I =
|
||||||
|
entrypoint f : () => int
|
||||||
|
|
||||||
|
contract C1 : I =
|
||||||
|
entrypoint f() = 123
|
||||||
|
|
||||||
|
contract C2 : I =
|
||||||
|
entrypoint f() = 888
|
||||||
|
|
||||||
|
namespace Make =
|
||||||
|
stateful function new1() : I = Chain.create() : C1
|
||||||
|
stateful function new2() : I = Chain.create() : C2
|
||||||
|
|
||||||
|
stateful function new(c : I) : int = c.f()
|
||||||
|
|
||||||
|
main contract Main =
|
||||||
|
stateful entrypoint test1() =
|
||||||
|
let c = Make.new1()
|
||||||
|
Make.new(c)
|
||||||
|
|
||||||
|
stateful entrypoint test2() =
|
||||||
|
let c = Make.new2()
|
||||||
|
Make.new(c)
|
||||||
|
|
||||||
|
stateful entrypoint test3() =
|
||||||
|
let c1 = Chain.create() : C1 // succeeds
|
||||||
|
let c2 : I = Chain.create() : C1 // succeeds
|
||||||
|
let c3 : C1 = Chain.create() // succeeds
|
||||||
|
()
|
@ -0,0 +1,12 @@
|
|||||||
|
contract interface I =
|
||||||
|
entrypoint f : () => int
|
||||||
|
|
||||||
|
contract C : I =
|
||||||
|
entrypoint f() = 123
|
||||||
|
|
||||||
|
main contract Main =
|
||||||
|
stateful entrypoint test() =
|
||||||
|
let c1 : I = Chain.create() // fails
|
||||||
|
let c2 : C = Chain.create() : I // fails
|
||||||
|
let c3 = Chain.create() : I // fails
|
||||||
|
()
|
Loading…
x
Reference in New Issue
Block a user