Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
If not able to find a symbol in the global environment, then also the…
Browse files Browse the repository at this point in the history
… pure environment, don't error out saying it's impure
  • Loading branch information
jspahrsummers committed Sep 28, 2011
1 parent 79b1d96 commit 01c4bca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion match.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function match.test (pattern, arg)
elseif pattern == any then
return true
end

return false
end

Expand Down
10 changes: 4 additions & 6 deletions pure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,7 @@ end

-- Error out on lookups in the pure environment that have been blacklisted
pure_mt.__index = function (table, key)
if table == pure_env then
error("'" .. key .. "' does not exist in pure environment", 2)
else
return nil
end
error("'" .. key .. "' does not exist in pure environment", 2)
end

-- When trying to set a new definition globally, validate purity.
Expand All @@ -203,4 +199,6 @@ global_mt.__newindex = function (table, key, value)
end

-- If lookup fails in global environment, check pure environment.
global_mt.__index = pure_env
global_mt.__index = function (table, key)
return rawget(pure_env, key)
end

0 comments on commit 01c4bca

Please sign in to comment.