diff options
author | Lua Team <team@lua.org> | 2000-11-06 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2000-11-06 12:00:00 +0000 |
commit | 8cb71cb5548e3138e5d4e4744f52c79d9fafb116 (patch) | |
tree | 25859eb162c67eafc46866e0ec3a9a7ebf93157a /test/undefined.lua | |
parent | b7610da5fed99f59ac73ae452da8839a0f2c1bda (diff) | |
download | lua-github-4.0.tar.gz |
Lua 4.04.0
Diffstat (limited to 'test/undefined.lua')
-rw-r--r-- | test/undefined.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/undefined.lua b/test/undefined.lua new file mode 100644 index 00000000..bbecffe3 --- /dev/null +++ b/test/undefined.lua @@ -0,0 +1,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 |