In many cases, TypeQL returns syntax errors that correctly identify the location of the syntax error, but make a generic and incorrect suggestion for how to fix it.
Environment
TypeDB version (and platform): Core 1.4 upwards
Reproducible Examples
Correct query: insert $e isa d-entity, has d-key 1;, missing a comma
insert $e isa d-entity has d-key 1;
Error: syntax error at line 1:
insert $e isa d-entity has d-key 1;
^
mismatched input 'has' expecting {'match', 'define', 'undefine', 'insert', 'compute'}
All uncommitted data is cleared
Correct query: define my-bool sub attribute, datatype boolean;
define my-bool sub attribute, datatype bool;
Error: syntax error at line 1:
define my-bool sub attribute, datatype bool;
^
mismatched input 'bool' expecting {'match', 'define', 'undefine', 'insert', 'compute'}
All uncommitted data is cleared
Correct query: insert $m isa my-bool; $m false;
insert $m isa my-bool false;
Error: syntax error at line 1:
insert $m isa my-bool false;
^
mismatched input 'false' expecting {'match', 'define', 'undefine', 'insert', 'compute'}
All uncommitted data is cleared
This example even gives an even stranger message. Correct query: define $m isa my-entity, has name; name sub attribute, datatype string;
define my-entity, has name; name sub attribute, datatype string;
Error: syntax error at line 1:
define my-entity, has name; name sub attribute, datatype string;
^
no viable alternative at input ','
syntax error at line 1:
define my-entity, has name; name sub attribute, datatype string;
^
mismatched input ',' expecting {'match', 'define', 'undefine', 'insert', 'compute'}
All uncommitted data is cleared
Query : define rel sub relation, relates has; (uses a keyword as role)
define
rel sub relation, relates has;
[TQL03] TypeQL Error: There is a syntax error at line 2:
rel sub relation, relates has;
^
mismatched input 'has' expecting {'get', 'thing', 'entity', 'attribute', 'relation', 'role', 'rule', 'offset', 'limit', 'sort', 'value', 'contains', 'group', 'count', 'max', 'min', 'mean', 'median', 'std', 'sum', VAR, LABEL}
## Expected Output
In each case, the suggestion `expecting {'match', 'define', 'undefine', 'insert', 'compute'}` is misleading. In all of these cases using these options is not valid. Ideally, the user should be prompted with all of the possible options that they could use instead at the point where their syntax is incorrect. At the least, they should be simply told the location of their syntax error, and not misguided.
Description
In many cases, TypeQL returns syntax errors that correctly identify the location of the syntax error, but make a generic and incorrect suggestion for how to fix it.
Environment
TypeDB version (and platform): Core 1.4 upwards
Reproducible Examples
Correct query:
insert $e isa d-entity, has d-key 1;
, missing a commaCorrect query:
define my-bool sub attribute, datatype boolean;
Correct query:
insert $m isa my-bool; $m false;
This example even gives an even stranger message. Correct query:
define $m isa my-entity, has name; name sub attribute, datatype string;
Query :
define rel sub relation, relates has;
(uses a keyword as role)[TQL03] TypeQL Error: There is a syntax error at line 2: rel sub relation, relates has; ^ mismatched input 'has' expecting {'get', 'thing', 'entity', 'attribute', 'relation', 'role', 'rule', 'offset', 'limit', 'sort', 'value', 'contains', 'group', 'count', 'max', 'min', 'mean', 'median', 'std', 'sum', VAR, LABEL}