Skip to content

Commit

Permalink
Add hygienic error for using strings in path, fixes #2337
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <[email protected]>
  • Loading branch information
Licenser committed Jul 21, 2023
1 parent b733b1d commit 48ba0e2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### New features

* hygienic errors for strings in path segements
* axiom stdlib module
* gcl now supports the `timestamp` metadata overwrite

Expand Down
1 change: 1 addition & 0 deletions tests/script_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ test_cases!(
pp_cyclic,
pp_nest_cyclic,
// INSERT
strnig_as_ident,
sub_overflow,
mul_overflow,
add_overflow,
Expand Down
4 changes: 4 additions & 0 deletions tests/script_errors/strnig_as_ident/error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Error:
1 | event."@timestamp"
| ^ Found the token `"` but expected `<ident>`
| NOTE: Did you mean to quote an ident? If so use ` (a back tick) not " (a quote).
1 change: 1 addition & 0 deletions tests/script_errors/strnig_as_ident/script.tremor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
event."@timestamp"
1 change: 1 addition & 0 deletions tremor-script/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ impl ErrorKind {
UnrecognizedToken(outer, inner, t, _) if t.is_empty() && inner.start().absolute() == outer.start().absolute() => Some("It looks like a `;` is missing at the end of the script".into()),
UnrecognizedToken(_, _, t, _) if t == "##" => Some(format!("`{t}` is as doc comment, it needs to be followed by a statement, did you want to use `#` here?")),
UnrecognizedToken(_, _, t, _) if t == "default" || t == "case" => Some("You might have a trailing `;` in the prior statement".into()),
UnrecognizedToken(_, _, t, l) if t == "\"" && l.contains(&("`<ident>`".to_string())) => Some("Did you mean to quote an ident? If so use ` (a back tick) not \" (a quote).".into()),
UnrecognizedToken(_, _, t, l) if !matches!(lexer::ident_to_token(t), lexer::Token::Ident(_, _)) && l.contains(&("`<ident>`".to_string())) => Some(format!("It looks like you tried to use '{t}' as an ident, consider quoting it as `{t}` to make it an identifier.")),
UnrecognizedToken(_, _, t, l) if t == "-" && l.contains(&("`(`".to_string())) => Some("Try wrapping this expression in parentheses `(` ... `)`".into()),
UnrecognizedToken(_, _, key, options) => {
Expand Down

0 comments on commit 48ba0e2

Please sign in to comment.