mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Better error message
This commit is contained in:
parent
d1b75b047b
commit
4137641c8c
@ -28,6 +28,7 @@ type unique_rulename = Ambiguous of Pos.t list | Unique of Desugared.Ast.RuleNam
|
||||
type scope_context = {
|
||||
var_idmap : Scopelang.Ast.ScopeVar.t Desugared.Ast.IdentMap.t; (** Scope variables *)
|
||||
label_idmap : Desugared.Ast.RuleName.t Desugared.Ast.IdentMap.t;
|
||||
(** Set of rules attached to a label *)
|
||||
default_rulemap : unique_rulename Desugared.Ast.ScopeDefMap.t;
|
||||
(** What is the default rule to refer to for unnamed exceptions, if any *)
|
||||
sub_scopes_idmap : Scopelang.Ast.SubScopeName.t Desugared.Ast.IdentMap.t;
|
||||
@ -460,8 +461,8 @@ let process_definition (ctxt : context) (s_name : Scopelang.Ast.ScopeName.t) (d
|
||||
match Desugared.Ast.IdentMap.find_opt (Pos.unmark label) s_ctxt.label_idmap with
|
||||
| Some existing_label ->
|
||||
Errors.raise_multispanned_error
|
||||
"This label has already been given to a rule defining this variable, \
|
||||
please pick a new one."
|
||||
"This label has already been given to another rule, please pick a new \
|
||||
one since labels should be unique."
|
||||
[
|
||||
(Some "Duplicate label:", Pos.get_position label);
|
||||
( Some "Existing rule with same label:",
|
||||
|
@ -1,4 +1,4 @@
|
||||
[ERROR] This label has already been given to a rule defining this variable, please pick a new one.
|
||||
[ERROR] This label has already been given to another rule, please pick a new one since labels should be unique.
|
||||
|
||||
Duplicate label:
|
||||
--> test_exception/bad/duplicate_labels.catala_en
|
||||
|
@ -0,0 +1,17 @@
|
||||
[ERROR] This label has already been given to another rule, please pick a new one since labels should be unique.
|
||||
|
||||
Duplicate label:
|
||||
--> test_exception/bad/same_label_two_variables.catala_en
|
||||
|
|
||||
13 | label base
|
||||
| ^^^^
|
||||
+ Test
|
||||
|
||||
Existing rule with same label:
|
||||
--> test_exception/bad/same_label_two_variables.catala_en
|
||||
|
|
||||
10 | label base
|
||||
| ^^^^^^^^^
|
||||
11 | definition x equals -1
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
+
|
20
tests/test_exception/bad/same_label_two_variables.catala_en
Normal file
20
tests/test_exception/bad/same_label_two_variables.catala_en
Normal file
@ -0,0 +1,20 @@
|
||||
## Test
|
||||
|
||||
```catala
|
||||
declaration scope A:
|
||||
context x content integer
|
||||
context y content integer
|
||||
context z content integer
|
||||
|
||||
scope A:
|
||||
label base
|
||||
definition x equals -1
|
||||
|
||||
label base
|
||||
definition y equals 1
|
||||
|
||||
exception base
|
||||
definition x under condition z = 0 consequence equals 0
|
||||
|
||||
definition z equals 0
|
||||
```
|
Loading…
Reference in New Issue
Block a user