Merge branch 'fix-gitlab-111' into 'dev'
Give a proper warning when creating an incorrect let binding. See merge request ligolang/ligo!376
This commit is contained in:
commit
87685861b9
@ -298,10 +298,11 @@ type action =
|
|||||||
|
|
||||||
let dest: address = ("KT19wgxcuXG9VH4Af5Tpm1vqEKdaMFpznXT3": address);
|
let dest: address = ("KT19wgxcuXG9VH4Af5Tpm1vqEKdaMFpznXT3": address);
|
||||||
|
|
||||||
let proxy = ((param, s): (action, unit)): (list(operation), unit) =>
|
let proxy = ((param, s): (action, unit)): (list(operation), unit) => {
|
||||||
let counter: contract(action) = Operation.get_contract(dest);
|
let counter: contract(action) = Operation.get_contract(dest);
|
||||||
let op: operation = Operation.transaction(param, 0mutez, counter);
|
let op: operation = Operation.transaction(param, 0mutez, counter);
|
||||||
([op], s);
|
([op], s);
|
||||||
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
<!--END_DOCUSAURUS_CODE_TABS-->
|
<!--END_DOCUSAURUS_CODE_TABS-->
|
||||||
|
23
src/bin/expect_tests/error_messages_tests.ml
Normal file
23
src/bin/expect_tests/error_messages_tests.ml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
open Cli_expect
|
||||||
|
|
||||||
|
let%expect_test _ =
|
||||||
|
run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/gitlab_111.religo" ; "main" ] ;
|
||||||
|
[%expect {|
|
||||||
|
ligo: : Parse error in file "gitlab_111.religo", line 2, characters 0-3, after "=" and before "let":
|
||||||
|
This is an incorrect let binding.
|
||||||
|
-
|
||||||
|
Examples of correct let bindings:
|
||||||
|
let a: int = 4;
|
||||||
|
let (a: int, b: int) = (1, 2);
|
||||||
|
let func = (a: int, b: int) => a + b;
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
If you're not sure how to fix this error, you can
|
||||||
|
do one of the following:
|
||||||
|
|
||||||
|
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
|
||||||
|
* Ask a question on our Discord: https://discord.gg/9rhYaEt
|
||||||
|
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
|
||||||
|
* Check the changelog by running 'ligo changelog' |} ] ;
|
||||||
|
|
@ -418,13 +418,13 @@ unit:
|
|||||||
(* Expressions *)
|
(* Expressions *)
|
||||||
|
|
||||||
interactive_expr:
|
interactive_expr:
|
||||||
expr EOF { $1 }
|
expr_with_let_expr EOF { $1 }
|
||||||
|
|
||||||
expr:
|
expr:
|
||||||
base_cond__open(expr) | switch_expr(base_cond) { $1 }
|
base_cond__open(expr) | switch_expr(base_cond) { $1 }
|
||||||
|
|
||||||
base_cond__open(x):
|
base_cond__open(x):
|
||||||
base_expr(x) | conditional(x) { $1 }
|
base_expr(x) | conditional(expr_with_let_expr) { $1 }
|
||||||
|
|
||||||
base_cond:
|
base_cond:
|
||||||
base_cond__open(base_cond) { $1 }
|
base_cond__open(base_cond) { $1 }
|
||||||
@ -567,7 +567,7 @@ fun_expr:
|
|||||||
in EFun {region; value=f} }
|
in EFun {region; value=f} }
|
||||||
|
|
||||||
base_expr(right_expr):
|
base_expr(right_expr):
|
||||||
let_expr(right_expr) | disj_expr_level | fun_expr { $1 }
|
disj_expr_level | fun_expr { $1 }
|
||||||
|
|
||||||
conditional(right_expr):
|
conditional(right_expr):
|
||||||
if_then_else(right_expr) | if_then(right_expr) { $1 }
|
if_then_else(right_expr) | if_then(right_expr) { $1 }
|
||||||
@ -609,6 +609,7 @@ base_if_then_else:
|
|||||||
closed_if:
|
closed_if:
|
||||||
base_if_then_else__open(closed_if)
|
base_if_then_else__open(closed_if)
|
||||||
| switch_expr(base_if_then_else) { $1 }
|
| switch_expr(base_if_then_else) { $1 }
|
||||||
|
| let_expr(expr_with_let_expr) { $1 }
|
||||||
|
|
||||||
switch_expr(right_expr):
|
switch_expr(right_expr):
|
||||||
"switch" switch_expr_ "{" cases(right_expr) "}" {
|
"switch" switch_expr_ "{" cases(right_expr) "}" {
|
||||||
@ -896,8 +897,12 @@ update_record:
|
|||||||
rbrace = $6}
|
rbrace = $6}
|
||||||
in {region; value} }
|
in {region; value} }
|
||||||
|
|
||||||
|
expr_with_let_expr:
|
||||||
|
expr { $1 }
|
||||||
|
| let_expr(expr_with_let_expr) { $1 }
|
||||||
|
|
||||||
sequence_or_record_in:
|
sequence_or_record_in:
|
||||||
expr ";" sep_or_term_list(expr,";") {
|
expr_with_let_expr ";" sep_or_term_list(expr_with_let_expr,";") {
|
||||||
let elts, _region = $3 in
|
let elts, _region = $3 in
|
||||||
let s_elts = Utils.nsepseq_cons $1 $2 elts
|
let s_elts = Utils.nsepseq_cons $1 $2 elts
|
||||||
in PaSequence {s_elts; s_terminator=None}
|
in PaSequence {s_elts; s_terminator=None}
|
||||||
@ -907,7 +912,7 @@ sequence_or_record_in:
|
|||||||
let r_elts = Utils.nsepseq_cons $1 $2 elts
|
let r_elts = Utils.nsepseq_cons $1 $2 elts
|
||||||
in PaRecord {r_elts; r_terminator = None}
|
in PaRecord {r_elts; r_terminator = None}
|
||||||
}
|
}
|
||||||
| expr ";"? { PaSingleExpr $1 }
|
| expr_with_let_expr ";"? { PaSingleExpr $1 }
|
||||||
|
|
||||||
sequence_or_record:
|
sequence_or_record:
|
||||||
"{" sequence_or_record_in "}" {
|
"{" sequence_or_record_in "}" {
|
||||||
|
File diff suppressed because it is too large
Load Diff
2
src/test/contracts/negative/gitlab_111.religo
Normal file
2
src/test/contracts/negative/gitlab_111.religo
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
let a =
|
||||||
|
let b = 2;
|
Loading…
Reference in New Issue
Block a user