summaryrefslogtreecommitdiff
path: root/test/undefined.lua
blob: bbecffe33fa6d6f551265a00b28f05853ebcad4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- catch "undefined" global variables. see FAQ.

do
 local f=function(name)
  local v=rawget(globals(),name)
  if v then
   return v
  else
   error("undefined global variable `"..name.."'")
  end
 end

 settagmethod(tag(nil),"getglobal",f)
end

-- an example

a=1
c=3
print(a,b,c)	-- 'b' is undefined