aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/import_global.lua
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-01-15 17:54:59 +0800
committerLi Jin <dragon-fly@qq.com>2026-01-15 17:54:59 +0800
commitafb046316a15a2c3702b1f056456b58e9356e693 (patch)
treec4820522be5c92948553673dad42c1734d30689f /spec/outputs/import_global.lua
parent873aced12cf65e633c95358f89a1d5ec37b81d00 (diff)
downloadyuescript-afb046316a15a2c3702b1f056456b58e9356e693.tar.gz
yuescript-afb046316a15a2c3702b1f056456b58e9356e693.tar.bz2
yuescript-afb046316a15a2c3702b1f056456b58e9356e693.zip
Added const attributes.
Diffstat (limited to 'spec/outputs/import_global.lua')
-rw-r--r--spec/outputs/import_global.lua46
1 files changed, 23 insertions, 23 deletions
diff --git a/spec/outputs/import_global.lua b/spec/outputs/import_global.lua
index c748c78..f76b4fe 100644
--- a/spec/outputs/import_global.lua
+++ b/spec/outputs/import_global.lua
@@ -1,11 +1,11 @@
1do 1do
2 local print = print 2 local print <const> = print
3 local math = math 3 local math <const> = math
4 print("hello") 4 print("hello")
5 math.random(10) 5 math.random(10)
6end 6end
7do 7do
8 local print = print 8 local print <const> = print
9 local value = 1 9 local value = 1
10 value = value + 2 10 value = value + 2
11 print(value) 11 print(value)
@@ -16,13 +16,13 @@ do
16 return msg 16 return msg
17 end 17 end
18 do 18 do
19 local math = math 19 local math <const> = math
20 print("local") 20 print("local")
21 math.random(1) 21 math.random(1)
22 end 22 end
23end 23end
24do 24do
25 local print = print 25 local print <const> = print
26 local tostring 26 local tostring
27 tostring = function(v) 27 tostring = function(v)
28 return "local" 28 return "local"
@@ -33,19 +33,19 @@ end
33do 33do
34 local func 34 local func
35 func = function(x, y) 35 func = function(x, y)
36 local type = type 36 local type <const> = type
37 local tostring = tostring 37 local tostring <const> = tostring
38 local print = print 38 local print <const> = print
39 return type(x, tostring(y, print)) 39 return type(x, tostring(y, print))
40 end 40 end
41 func(1, 2) 41 func(1, 2)
42end 42end
43do 43do
44 local xpcall = xpcall 44 local xpcall <const> = xpcall
45 local func = func 45 local func <const> = func
46 local world = world 46 local world <const> = world
47 local tostring = tostring 47 local tostring <const> = tostring
48 local print = print 48 local print <const> = print
49 xpcall(function() 49 xpcall(function()
50 return func("hello " .. tostring(world)) 50 return func("hello " .. tostring(world))
51 end, function(err) 51 end, function(err)
@@ -53,40 +53,40 @@ do
53 end) 53 end)
54end 54end
55do 55do
56 local print = print 56 local print <const> = print
57 print(FLAG) 57 print(FLAG)
58 FLAG = 123 58 FLAG = 123
59end 59end
60do 60do
61 local print = print 61 local print <const> = print
62 Foo = 10 62 Foo = 10
63 print(Foo) 63 print(Foo)
64 Foo = Foo + 2 64 Foo = Foo + 2
65end 65end
66do 66do
67 local print = print 67 local print <const> = print
68 Bar = 1 68 Bar = 1
69 Baz = 2 69 Baz = 2
70 print(Bar, Baz) 70 print(Bar, Baz)
71end 71end
72do 72do
73 local y = y 73 local y <const> = y
74 x = 3434 74 x = 3434
75 if y then 75 if y then
76 x = 10 76 x = 10
77 end 77 end
78end 78end
79do 79do
80 local lowercase = lowercase 80 local lowercase <const> = lowercase
81 local tostring = tostring 81 local tostring <const> = tostring
82 local Uppercase = Uppercase 82 local Uppercase <const> = Uppercase
83 local foobar = "all " .. tostring(lowercase) 83 local foobar = "all " .. tostring(lowercase)
84 FooBar = "pascal case" 84 FooBar = "pascal case"
85 FOOBAR = "all " .. tostring(Uppercase) 85 FOOBAR = "all " .. tostring(Uppercase)
86end 86end
87do 87do
88 local setmetatable = setmetatable 88 local setmetatable <const> = setmetatable
89 local print = print 89 local print <const> = print
90 do 90 do
91 local _class_0 91 local _class_0
92 local _base_0 = { } 92 local _base_0 = { }
@@ -113,7 +113,7 @@ do
113 print(math, table) 113 print(math, table)
114end 114end
115do 115do
116 local X = X 116 local X <const> = X
117 X:func(1, 2, 3) 117 X:func(1, 2, 3)
118 X.tag = "abc" 118 X.tag = "abc"
119 return X 119 return X