diff options
| author | Lua Team <team@lua.org> | 2003-04-11 12:00:00 +0000 |
|---|---|---|
| committer | repogen <> | 2003-04-11 12:00:00 +0000 |
| commit | f0e4e22f5c119865eb5a8d3844a40df2d5980b3b (patch) | |
| tree | c4df063a747e9c99f8aba1678588a030993780a9 /test/undefined.lua | |
| parent | 1981b7c90eb09e956e969cda5c473be4560af573 (diff) | |
| download | lua-github-5.0.tar.gz | |
Lua 5.05.0
Diffstat (limited to 'test/undefined.lua')
| -rw-r--r-- | test/undefined.lua | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/test/undefined.lua b/test/undefined.lua index bbecffe3..efe5f245 100644 --- a/test/undefined.lua +++ b/test/undefined.lua @@ -1,20 +1,9 @@ --- catch "undefined" global variables. see FAQ. +-- catch "undefined" global variables -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 +local f=function (t,i) error("undefined global variable `"..i.."'",2) end +setmetatable(getfenv(),{__index=f}) -- an example - a=1 c=3 -print(a,b,c) -- 'b' is undefined +print(a,b,c) -- `b' is undefined |
