Fix error messages for some illegal constructions, fix absolute path includes #742
@ -2263,8 +2263,8 @@ mk_t_err(Pos, Msg, Ctxt) ->
|
||||
aeso_errors:new(type_error, Pos, lists:flatten(Msg), lists:flatten(Ctxt)).
|
||||
|
||||
mk_error({higher_kinded_typevar, T}) ->
|
||||
Msg = io_lib:format("Type ~s is higher kinded (takes a type argument that takes\n"
|
||||
"a type argument)\n", [pp(instantiate(T))]
|
||||
Msg = io_lib:format("Type ~s is a higher kinded type variable\n"
|
||||
"(takes another type as an argument)\n", [pp(instantiate(T))]
|
||||
),
|
||||
mk_t_err(pos(T), Msg);
|
||||
mk_error({wrong_type_arguments, X, ArityGiven, ArityReal}) ->
|
||||
|
@ -375,11 +375,15 @@ failing_contracts() ->
|
||||
" r.foo : (gas : int, value : int) => Remote.themap\n"
|
||||
"against the expected type\n"
|
||||
" (gas : int, value : int) => map(string, int)">>])
|
||||
, ?TYPE_ERROR(bad_include_and_ns,
|
||||
, ?TYPE_ERROR(not_toplevel_include,
|
||||
[<<?Pos(2, 11)
|
||||
"Include of 'included.aes' at line 2, column 11\nnot allowed, include only allowed at top level.">>,
|
||||
<<?Pos(3, 13)
|
||||
"Nested namespaces are not allowed\nNamespace 'Foo' at line 3, column 13 not defined at top level.">>])
|
||||
"Include of 'included.aes' at line 2, column 11\nnot allowed, include only allowed at top level.">>])
|
||||
, ?TYPE_ERROR(not_toplevel_namespace,
|
||||
[<<?Pos(2, 13)
|
||||
"Nested namespaces are not allowed\nNamespace 'Foo' at line 2, column 13 not defined at top level.">>])
|
||||
, ?TYPE_ERROR(not_toplevel_contract,
|
||||
[<<?Pos(2, 12)
|
||||
"Nested contracts are not allowed\nContract 'Con' at line 2, column 12 not defined at top level.">>])
|
||||
, ?TYPE_ERROR(bad_address_literals,
|
||||
[<<?Pos(11, 5)
|
||||
"Cannot unify address\n"
|
||||
@ -612,6 +616,44 @@ failing_contracts() ->
|
||||
[<<?Pos(5, 28)
|
||||
"Invalid call to contract entrypoint 'Foo.foo'.\n"
|
||||
"It must be called as 'c.foo' for some c : Foo.">>])
|
||||
, ?TYPE_ERROR(toplevel_let,
|
||||
[<<?Pos(2, 7)
|
||||
"Toplevel \"let\" definitions are not supported\n"
|
||||
"Value this_is_illegal at line 2, column 7 could be replaced by 0-argument function">>])
|
||||
, ?TYPE_ERROR(empty_typedecl,
|
||||
[<<?Pos(2, 8)
|
||||
"Empty type declarations are not supported\n"
|
||||
"Type t at line 2, column 8 lacks a definition">>])
|
||||
, ?TYPE_ERROR(higher_kinded_type,
|
||||
[<<?Pos(2, 35)
|
||||
"Type 'm is a higher kinded type variable\n"
|
||||
"(takes another type as an argument)">>])
|
||||
, ?TYPE_ERROR(bad_arity,
|
||||
[<<?Pos(3, 20)
|
||||
"Arity for id doesn't match. Expected 1, got 0">>,
|
||||
<<?Pos(3, 25)
|
||||
"Cannot unify int\n"
|
||||
" and id\n"
|
||||
"when checking the type of the expression at line 3, column 25\n"
|
||||
" 123 : int\n"
|
||||
"against the expected type\n"
|
||||
" id">>,
|
||||
<<?Pos(4, 20)
|
||||
"Arity for id doesn't match. Expected 1, got 2">>,
|
||||
<<?Pos(4, 35)
|
||||
"Cannot unify int\n"
|
||||
" and id(int, int)\n"
|
||||
"when checking the type of the expression at line 4, column 35\n"
|
||||
" 123 : int\n"
|
||||
"against the expected type\n"
|
||||
" id(int, int)">>])
|
||||
, ?TYPE_ERROR(bad_unnamed_map_update_default,
|
||||
[<<?Pos(4, 17)
|
||||
"Invalid map update with default">>])
|
||||
, ?TYPE_ERROR(non_functional_entrypoint,
|
||||
[<<?Pos(2, 14)
|
||||
"f at line 2, column 14 was declared with an invalid type int.\n"
|
||||
"Entrypoints and functions must have functional types">>])
|
||||
, ?TYPE_ERROR(bad_records,
|
||||
[<<?Pos(3, 16)
|
||||
"Mixed record fields and map keys in\n"
|
||||
|
4
test/contracts/bad_arity.aes
Normal file
4
test/contracts/bad_arity.aes
Normal file
@ -0,0 +1,4 @@
|
||||
contract C =
|
||||
type id('a) = 'a
|
||||
entrypoint f() : id = 123
|
||||
entrypoint g() : id(int, int) = 123
|
5
test/contracts/bad_unnamed_map_update_default.aes
Normal file
5
test/contracts/bad_unnamed_map_update_default.aes
Normal file
@ -0,0 +1,5 @@
|
||||
contract C =
|
||||
entrypoint f() =
|
||||
let z = 123
|
||||
{}{ [1 = 0] = z + 1 }
|
||||
2
|
3
test/contracts/empty_typedecl.aes
Normal file
3
test/contracts/empty_typedecl.aes
Normal file
@ -0,0 +1,3 @@
|
||||
contract C =
|
||||
type t
|
||||
entrypoint f() = 123
|
3
test/contracts/higher_kinded_type.aes
Normal file
3
test/contracts/higher_kinded_type.aes
Normal file
@ -0,0 +1,3 @@
|
||||
contract IWantToBelieve =
|
||||
type stateT('s, 'm, 'a) = 's => 'm('a * 's)
|
||||
entrypoint s() = 123
|
5
test/contracts/non_functional_entrypoint.aes
Normal file
5
test/contracts/non_functional_entrypoint.aes
Normal file
@ -0,0 +1,5 @@
|
||||
contract C1 =
|
||||
entrypoint f : int
|
||||
|
||||
contract C =
|
||||
entrypoint f() = 123
|
6
test/contracts/not_toplevel_contract.aes
Normal file
6
test/contracts/not_toplevel_contract.aes
Normal file
@ -0,0 +1,6 @@
|
||||
namespace BadNs =
|
||||
contract Con =
|
||||
entrypoint e : () => int
|
||||
|
||||
contract Con =
|
||||
entrypoint foo() = 43
|
5
test/contracts/not_toplevel_include.aes
Normal file
5
test/contracts/not_toplevel_include.aes
Normal file
@ -0,0 +1,5 @@
|
||||
namespace BadNs =
|
||||
include "included.aes"
|
||||
|
||||
contract Con =
|
||||
entrypoint foo() = 43
|
@ -1,5 +1,4 @@
|
||||
contract Bad =
|
||||
include "included.aes"
|
||||
contract BadCon =
|
||||
namespace Foo =
|
||||
function foo() = 42
|
||||
|
3
test/contracts/toplevel_let.aes
Normal file
3
test/contracts/toplevel_let.aes
Normal file
@ -0,0 +1,3 @@
|
||||
contract C =
|
||||
let this_is_illegal = 2/0
|
||||
entrypoint this_is_legal() = 2/0
|
Loading…
x
Reference in New Issue
Block a user