diff options
| author | Ian Wrzesinski <133046678+wrzian@users.noreply.github.com> | 2024-10-31 07:55:31 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-31 11:55:31 +0000 |
| commit | dcb130bd710a775846b94ba340c7be833a4fad2b (patch) | |
| tree | fe8e99ed326ef7031bd2f29e0dd01fe5dcbee113 | |
| parent | b969c01b282287b44c3e131f8c0c53dcbb304e30 (diff) | |
Add a warning for `is` to anticipate using it as a keyword (#5229)
Co-authored-by: Malo <57839069+MDLC01@users.noreply.github.com>
| -rw-r--r-- | crates/typst-eval/src/vm.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/typst-eval/src/vm.rs b/crates/typst-eval/src/vm.rs index 1c8331b6..adf7dd76 100644 --- a/crates/typst-eval/src/vm.rs +++ b/crates/typst-eval/src/vm.rs @@ -1,4 +1,5 @@ use comemo::Tracked; +use typst_library::diag::warning; use typst_library::engine::Engine; use typst_library::foundations::{Context, IntoValue, Scopes, Value}; use typst_library::World; @@ -47,6 +48,16 @@ impl<'a> Vm<'a> { if self.inspected == Some(var.span()) { self.trace(value.clone()); } + // This will become an error in the parser if 'is' becomes a keyword. + if var.get() == "is" { + self.engine.sink.warn(warning!( + var.span(), + "`is` will likely become a keyword in future versions and will \ + not be allowed as an identifier"; + hint: "rename this variable to avoid future errors"; + hint: "try `is_` instead" + )); + } self.scopes.top.define_ident(var, value); } |
