Skip to content

Commit

Permalink
added warning when using const without targeting lua 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Enn3Developer committed Jun 26, 2024
1 parent 0797cfc commit 92b26ea
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions core/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,19 @@ impl<'a> ParserInfo<'a> {
fn parse_token_local_global(&mut self, t: &BorrowedToken) -> Result<(), String> {
let local = t.kind() == LOCAL;
let r#const = t.kind() == CONST || self.advance_if(CONST);
if r#const
&& (self.options.env_target.is_none()
|| self
.options
.env_target
.is_some_and(|lua| lua != LuaVersion::Lua54))
{
println!(
"Warning: Using `const` without targeting Lua 5.4 {}:{}",
t.line(),
t.column()
);
}
match self.peek(0).kind() {
FN => {
let function = self.build_function(local)?;
Expand All @@ -1962,6 +1975,19 @@ impl<'a> ParserInfo<'a> {

fn parse_token_static(&mut self, t: &BorrowedToken) -> Result<(), String> {
let r#const = t.kind() == CONST || self.advance_if(CONST);
if r#const
&& (self.options.env_target.is_none()
|| self
.options
.env_target
.is_some_and(|lua| lua != LuaVersion::Lua54))
{
println!(
"Warning: Using `const` without targeting Lua 5.4 {}:{}",
t.line(),
t.column()
);
}
match self.peek(0).kind() {
FN => {
let function = vec_deque![self.build_function(true)?];
Expand Down

0 comments on commit 92b26ea

Please sign in to comment.