Skip to content

Commit

Permalink
Add unscoped variables fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscerie committed Oct 16, 2023
1 parent a94b9ac commit b395454
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions selene-lib/src/lints/unscoped_variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ impl Lint for UnscopedVariablesLint {
reference.name
),
Label::new(reference.identifier),
None,
Applicability::Unspecified,
Some(format!("local {}", reference.name)),
Applicability::MaybeIncorrect,
));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-[MI] bar = true
+[MI] local bar = true

local foo = 1
foo = 2

local bar = 1
bar = 2

pcall(function()
foo = 3
-[MI] baz = 1
+[MI] local baz = 1
end)

_ = 3
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ error[unscoped_variables]: `bar` is not declared locally, and will be available
1 │ bar = true
│ ^^^
= try: `local bar`

error[unscoped_variables]: `baz` is not declared locally, and will be available in every scope
┌─ unscoped_variables.lua:11:5
11 │ baz = 1
│ ^^^
= try: `local baz`

0 comments on commit b395454

Please sign in to comment.