Fixed again priority of "->" vs "*" in type expressions.
Fixed negative tests.
This commit is contained in:
parent
47a41971d7
commit
3c9dd93c8b
@ -3,7 +3,8 @@ open Cli_expect
|
||||
let%expect_test _ =
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/broken_string.ligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: The string starting here is interrupted by a line break.
|
||||
ligo: : Lexical error in file "broken_string.ligo", line 1, characters 18-19:
|
||||
The string starting here is interrupted by a line break.
|
||||
Hint: Remove the break, close the string before or insert a backslash.
|
||||
{"parser_loc":"in file \"broken_string.ligo\", line 1, characters 18-19"}
|
||||
|
||||
@ -19,7 +20,8 @@ ligo: lexer error: The string starting here is interrupted by a line break.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/broken_string.mligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: The string starting here is interrupted by a line break.
|
||||
ligo: : Lexical error at line 1, characters 8-9:
|
||||
The string starting here is interrupted by a line break.
|
||||
Hint: Remove the break, close the string before or insert a backslash.
|
||||
{"parser_loc":"in file \"broken_string.mligo\", line 1, characters 8-9"}
|
||||
|
||||
@ -35,7 +37,8 @@ ligo: lexer error: The string starting here is interrupted by a line break.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/broken_string.religo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: The string starting here is interrupted by a line break.
|
||||
ligo: : Lexical error at line 1, characters 8-9:
|
||||
The string starting here is interrupted by a line break.
|
||||
Hint: Remove the break, close the string before or insert a backslash.
|
||||
{"parser_loc":"in file \"broken_string.religo\", line 1, characters 8-9"}
|
||||
|
||||
@ -51,7 +54,8 @@ ligo: lexer error: The string starting here is interrupted by a line break.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/negative_byte_sequence.ligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Negative byte sequence.
|
||||
ligo: : Lexical error in file "negative_byte_sequence.ligo", line 1, characters 18-23:
|
||||
Negative byte sequence.
|
||||
Hint: Remove the leading minus sign.
|
||||
{"parser_loc":"in file \"negative_byte_sequence.ligo\", line 1, characters 18-23"}
|
||||
|
||||
@ -67,7 +71,8 @@ ligo: lexer error: Negative byte sequence.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/negative_byte_sequence.mligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Negative byte sequence.
|
||||
ligo: : Lexical error at line 1, characters 8-13:
|
||||
Negative byte sequence.
|
||||
Hint: Remove the leading minus sign.
|
||||
{"parser_loc":"in file \"negative_byte_sequence.mligo\", line 1, characters 8-13"}
|
||||
|
||||
@ -83,7 +88,8 @@ ligo: lexer error: Negative byte sequence.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/negative_byte_sequence.religo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Negative byte sequence.
|
||||
ligo: : Lexical error at line 1, characters 8-13:
|
||||
Negative byte sequence.
|
||||
Hint: Remove the leading minus sign.
|
||||
{"parser_loc":"in file \"negative_byte_sequence.religo\", line 1, characters 8-13"}
|
||||
|
||||
@ -99,7 +105,8 @@ ligo: lexer error: Negative byte sequence.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/reserved_name.ligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Reserved name: arguments.
|
||||
ligo: : Lexical error in file "reserved_name.ligo", line 1, characters 4-13:
|
||||
Reserved name: arguments.
|
||||
Hint: Change the name.
|
||||
{"parser_loc":"in file \"reserved_name.ligo\", line 1, characters 4-13"}
|
||||
|
||||
@ -115,7 +122,8 @@ ligo: lexer error: Reserved name: arguments.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/reserved_name.religo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Reserved name: end.
|
||||
ligo: : Lexical error at line 1, characters 4-7:
|
||||
Reserved name: end.
|
||||
Hint: Change the name.
|
||||
{"parser_loc":"in file \"reserved_name.religo\", line 1, characters 4-7"}
|
||||
|
||||
@ -131,7 +139,8 @@ ligo: lexer error: Reserved name: end.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/reserved_name.mligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Reserved name: object.
|
||||
ligo: : Lexical error at line 1, characters 4-10:
|
||||
Reserved name: object.
|
||||
Hint: Change the name.
|
||||
{"parser_loc":"in file \"reserved_name.mligo\", line 1, characters 4-10"}
|
||||
|
||||
@ -147,7 +156,8 @@ ligo: lexer error: Reserved name: object.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/unexpected_character.ligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Unexpected character '\239'.
|
||||
ligo: : Lexical error in file "unexpected_character.ligo", line 1, characters 18-19:
|
||||
Unexpected character '\239'.
|
||||
{"parser_loc":"in file \"unexpected_character.ligo\", line 1, characters 18-19"}
|
||||
|
||||
|
||||
@ -162,7 +172,8 @@ ligo: lexer error: Unexpected character '\239'.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/unexpected_character.mligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Unexpected character '\239'.
|
||||
ligo: : Lexical error at line 1, characters 8-9:
|
||||
Unexpected character '\239'.
|
||||
{"parser_loc":"in file \"unexpected_character.mligo\", line 1, characters 8-9"}
|
||||
|
||||
|
||||
@ -177,7 +188,8 @@ ligo: lexer error: Unexpected character '\239'.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/unexpected_character.religo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Unexpected character '\239'.
|
||||
ligo: : Lexical error at line 1, characters 8-9:
|
||||
Unexpected character '\239'.
|
||||
{"parser_loc":"in file \"unexpected_character.religo\", line 1, characters 8-9"}
|
||||
|
||||
|
||||
@ -192,7 +204,8 @@ ligo: lexer error: Unexpected character '\239'.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/unterminated_comment.mligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Unterminated comment.
|
||||
ligo: : Lexical error at line 1, characters 0-2:
|
||||
Unterminated comment.
|
||||
Hint: Close with "*)".
|
||||
{"parser_loc":"in file \"unterminated_comment.mligo\", line 1, characters 0-2"}
|
||||
|
||||
@ -208,7 +221,8 @@ ligo: lexer error: Unterminated comment.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_symbol.ligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Invalid symbol.
|
||||
ligo: : Lexical error in file "invalid_symbol.ligo", line 1, characters 17-20:
|
||||
Invalid symbol.
|
||||
Hint: Check the LIGO syntax you use.
|
||||
{"parser_loc":"in file \"invalid_symbol.ligo\", line 1, characters 17-20"}
|
||||
|
||||
@ -224,7 +238,8 @@ ligo: lexer error: Invalid symbol.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_symbol.mligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Invalid symbol.
|
||||
ligo: : Lexical error at line 1, characters 10-13:
|
||||
Invalid symbol.
|
||||
Hint: Check the LIGO syntax you use.
|
||||
{"parser_loc":"in file \"invalid_symbol.mligo\", line 1, characters 10-13"}
|
||||
|
||||
@ -240,7 +255,8 @@ ligo: lexer error: Invalid symbol.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_symbol.religo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Invalid symbol.
|
||||
ligo: : Lexical error at line 1, characters 10-11:
|
||||
Invalid symbol.
|
||||
Hint: Check the LIGO syntax you use.
|
||||
{"parser_loc":"in file \"invalid_symbol.religo\", line 1, characters 10-11"}
|
||||
|
||||
@ -256,7 +272,8 @@ ligo: lexer error: Invalid symbol.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/missing_break.ligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Missing break.
|
||||
ligo: : Lexical error in file "missing_break.ligo", line 1, characters 18-18:
|
||||
Missing break.
|
||||
Hint: Insert some space.
|
||||
{"parser_loc":"in file \"missing_break.ligo\", line 1, characters 18-18"}
|
||||
|
||||
@ -272,7 +289,8 @@ ligo: lexer error: Missing break.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/missing_break.mligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Missing break.
|
||||
ligo: : Lexical error at line 1, characters 11-11:
|
||||
Missing break.
|
||||
Hint: Insert some space.
|
||||
{"parser_loc":"in file \"missing_break.mligo\", line 1, characters 11-11"}
|
||||
|
||||
@ -288,7 +306,8 @@ ligo: lexer error: Missing break.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/missing_break.religo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Missing break.
|
||||
ligo: : Lexical error at line 1, characters 11-11:
|
||||
Missing break.
|
||||
Hint: Insert some space.
|
||||
{"parser_loc":"in file \"missing_break.religo\", line 1, characters 11-11"}
|
||||
|
||||
@ -304,7 +323,8 @@ ligo: lexer error: Missing break.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_character_in_string.ligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Invalid character in string.
|
||||
ligo: : Lexical error in file "invalid_character_in_string.ligo", line 1, characters 19-20:
|
||||
Invalid character in string.
|
||||
Hint: Remove or replace the character.
|
||||
{"parser_loc":"in file \"invalid_character_in_string.ligo\", line 1, characters 19-20"}
|
||||
|
||||
@ -320,7 +340,8 @@ ligo: lexer error: Invalid character in string.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_character_in_string.mligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Invalid character in string.
|
||||
ligo: : Lexical error at line 1, characters 9-10:
|
||||
Invalid character in string.
|
||||
Hint: Remove or replace the character.
|
||||
{"parser_loc":"in file \"invalid_character_in_string.mligo\", line 1, characters 9-10"}
|
||||
|
||||
@ -336,7 +357,8 @@ ligo: lexer error: Invalid character in string.
|
||||
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/lexer/invalid_character_in_string.religo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: lexer error: Invalid character in string.
|
||||
ligo: : Lexical error at line 1, characters 9-10:
|
||||
Invalid character in string.
|
||||
Hint: Remove or replace the character.
|
||||
{"parser_loc":"in file \"invalid_character_in_string.religo\", line 1, characters 9-10"}
|
||||
|
||||
|
@ -3,8 +3,8 @@ open Cli_expect
|
||||
let%expect_test _ =
|
||||
run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_syntax.ligo" ; "main" ] ;
|
||||
[%expect {|
|
||||
ligo: parser error: Parse error at "-" from (1, 16) to (1, 17). In file "|../../test/contracts/negative/error_syntax.ligo"
|
||||
{"parser_loc":"in file \"\", line 1, characters 16-17"}
|
||||
ligo: : Parse error in file "error_syntax.ligo", line 1, characters 16-17, after "bar" and before "-".
|
||||
{"parser_loc":"in file \"error_syntax.ligo\", line 1, characters 16-17"}
|
||||
|
||||
|
||||
If you're not sure how to fix this error, you can
|
||||
|
@ -182,7 +182,7 @@ sum_type:
|
||||
|
||||
variant:
|
||||
"<constr>" { {$1 with value={constr=$1; arg=None}} }
|
||||
| "<constr>" "of" cartesian {
|
||||
| "<constr>" "of" fun_type {
|
||||
let region = cover $1.region (type_expr_to_region $3)
|
||||
and value = {constr=$1; arg = Some ($2,$3)}
|
||||
in {region; value} }
|
||||
|
@ -201,7 +201,7 @@ sum_type:
|
||||
|
||||
variant:
|
||||
"<constr>" { {$1 with value = {constr=$1; arg=None}} }
|
||||
| "<constr>" "of" cartesian {
|
||||
| "<constr>" "of" fun_type {
|
||||
let region = cover $1.region (type_expr_to_region $3)
|
||||
and value = {constr=$1; arg = Some ($2,$3)}
|
||||
in {region; value} }
|
||||
@ -315,7 +315,7 @@ param_decl:
|
||||
in ParamConst {region; value} }
|
||||
|
||||
param_type:
|
||||
cartesian { $1 }
|
||||
fun_type { $1 }
|
||||
|
||||
block:
|
||||
"begin" sep_or_term_list(statement,";") "end" {
|
||||
|
@ -1,52 +1,45 @@
|
||||
// Test a PascaLIGO function which takes another PascaLIGO function as an argument
|
||||
function foobar (const i : int) : int is
|
||||
block {
|
||||
function foo (const i : int) : int is
|
||||
i ;
|
||||
function bar (const f : int -> int) : int is
|
||||
f ( i ) ;
|
||||
} with bar (foo) ;
|
||||
begin
|
||||
function foo (const i : int) : int is i;
|
||||
function bar (const f : int -> int) : int is f (i);
|
||||
end with bar (foo);
|
||||
|
||||
// higher order function with more than one argument
|
||||
function higher2(const i: int; const f: int -> int): int is
|
||||
block {
|
||||
const ii: int = f(i)
|
||||
} with ii
|
||||
function higher2(const i : int; const f : int -> int): int is
|
||||
begin
|
||||
const ii: int = f (i)
|
||||
end with ii
|
||||
|
||||
function foobar2 (const i : int) : int is
|
||||
block {
|
||||
function foo2 (const i : int) : int is
|
||||
i;
|
||||
} with higher2(i,foo2)
|
||||
begin
|
||||
function foo2 (const i : int) : int is i
|
||||
end with higher2 (i,foo2)
|
||||
|
||||
const a : int = 0;
|
||||
|
||||
function foobar3 (const i : int) : int is
|
||||
block {
|
||||
function foo2 (const i : int) : int is
|
||||
(a+i);
|
||||
} with higher2(i,foo2)
|
||||
begin
|
||||
function foo2 (const i : int) : int is a+i
|
||||
end with higher2 (i,foo2)
|
||||
|
||||
function f (const i : int) : int is
|
||||
i
|
||||
function f (const i : int) : int is i
|
||||
|
||||
function g (const i : int) : int is
|
||||
f(i)
|
||||
function g (const i : int) : int is f (i)
|
||||
|
||||
function foobar4 (const i : int) : int is
|
||||
g(g(i))
|
||||
function foobar4 (const i : int) : int is g (g (i))
|
||||
|
||||
function higher3(const i: int; const f: int -> int; const g: int -> int): int is
|
||||
block {
|
||||
const ii: int = f(g(i));
|
||||
} with ii
|
||||
function higher3(const i : int; const f : int -> int; const g : int -> int)
|
||||
: int is
|
||||
begin
|
||||
const ii : int = f(g(i))
|
||||
end with ii
|
||||
|
||||
function foobar5 (const i : int) : int is
|
||||
block {
|
||||
begin
|
||||
const a : int = 0;
|
||||
function foo (const i : int) : int is
|
||||
(a+i);
|
||||
function goo (const i : int) : int is
|
||||
foo(i);
|
||||
} with higher3(i,foo,goo)
|
||||
function foo (const i : int) : int is a+i;
|
||||
function goo (const i : int) : int is foo (i)
|
||||
end with higher3(i,foo,goo)
|
||||
|
||||
function foobar6 (const i : int) : (int->int) is f
|
||||
function foobar6 (const i : int) : int -> int is f
|
||||
|
Loading…
Reference in New Issue
Block a user