Skip to content

Commit 0249104

Browse files
committed
Add example to showcase semantic highlighting
1 parent 7b15c4a commit 0249104

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

example.lua

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
-- A local variable masking a global one:
2+
global_variable = '1st value'
3+
do
4+
local global_variable = 'NOT ACTUALLY A GLOBAL!'
5+
print(global_variable)
6+
end
7+
global_variable = '2nd value'
8+
9+
-- Highlighting for different types of locals:
10+
local usedlocal = 'this is a local variable'
11+
local mutated = "this one's assigned multiple times"
12+
local unused = "and this one isn't referenced anywhere"
13+
mutated = 'this is the second value of [mutated]'
14+
print(usedlocal)
15+
print(undefined)
16+
17+
io.open('')
18+
string.lower('')
19+
local tinsert = table.insert
20+
local test = { field = function(foo, bar, baz) print(baz) end }
21+
22+
-- Highlighting for function arguments:
23+
local function example(usedparam, mutatedparam, unusedparam)
24+
mutatedparam = 42
25+
print(usedparam)
26+
end
27+
28+
-- Argument count checking:
29+
30+
example(1)
31+
32+
for k, v in pairs(_G) do print(k) end
33+
34+
example (
35+
1,
36+
2,
37+
3,
38+
4)
39+
40+
-- Syntax errors:
41+
-- example(..)

0 commit comments

Comments
 (0)