mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Add a warning for is
to anticipate using it as a keyword (#5229)
Co-authored-by: Malo <57839069+MDLC01@users.noreply.github.com>
This commit is contained in:
parent
b969c01b28
commit
dcb130bd71
@ -1,4 +1,5 @@
|
|||||||
use comemo::Tracked;
|
use comemo::Tracked;
|
||||||
|
use typst_library::diag::warning;
|
||||||
use typst_library::engine::Engine;
|
use typst_library::engine::Engine;
|
||||||
use typst_library::foundations::{Context, IntoValue, Scopes, Value};
|
use typst_library::foundations::{Context, IntoValue, Scopes, Value};
|
||||||
use typst_library::World;
|
use typst_library::World;
|
||||||
@ -47,6 +48,16 @@ impl<'a> Vm<'a> {
|
|||||||
if self.inspected == Some(var.span()) {
|
if self.inspected == Some(var.span()) {
|
||||||
self.trace(value.clone());
|
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);
|
self.scopes.top.define_ident(var, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user