aboutsummaryrefslogtreecommitdiff
path: root/core/collections.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-08-27 13:38:58 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-08-27 13:39:22 -0700
commit930d522fbc3ab57faa926ed85f0d35d661722402 (patch)
tree8c91c71728b43b4e1817ed182c39bf991cb4b2a9 /core/collections.nom
parentc6a7b0be9ebdddb58a03749705987cb3058060d3 (diff)
Bunch of miscellaneous changes. Paved the way a little bit for having
different compiler domains.
Diffstat (limited to 'core/collections.nom')
-rw-r--r--core/collections.nom15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/collections.nom b/core/collections.nom
index 8553d66..8270f62 100644
--- a/core/collections.nom
+++ b/core/collections.nom
@@ -191,11 +191,16 @@ test:
assume (({} with fallback % -> (% + 1)).10 == 11)
compile [%dict with fallback %key -> %value] to (..)
Lua value ".."
- setmetatable(\(%dict as lua expr), {__index=function(self, \(%key as lua expr))
- local value = \(%value as lua expr)
- self[\(%key as lua expr)] = value
- return value
- end})
+ (function(d)
+ local mt = {}
+ for k,v in pairs(getmetatable(d) or {}) do mt[k] = v end
+ mt.__index = function(self, \(%key as lua expr))
+ local value = \(%value as lua expr)
+ self[\(%key as lua expr)] = value
+ return value
+ end
+ return setmetatable(d, mt)
+ end)(\(%dict as lua expr))
# Sorting
test: