@@ -280,15 +280,18 @@ moduleToJs (Module coms mn imps exps foreigns decls) foreign_ =
280280 extendObj obj sts = do
281281 newObj <- freshName
282282 key <- freshName
283+ evaluatedObj <- freshName
283284 let
284285 jsKey = JSVar Nothing key
285286 jsNewObj = JSVar Nothing newObj
286− block = JSBlock Nothing (objAssign:copy:extend ++ [JSReturn Nothing jsNewObj])
287+ jsEvaluatedObj = JSVar Nothing evaluatedObj
288+ block = JSBlock Nothing (evaluate:objAssign:copy:extend ++ [JSReturn Nothing jsNewObj])
289+ evaluate = JSVariableIntroduction Nothing evaluatedObj (Just obj)
287290 objAssign = JSVariableIntroduction Nothing newObj (Just $ JSObjectLiteral Nothing [])
288− copy = JSForIn Nothing key obj $ JSBlock Nothing [JSIfElse Nothing cond assign Nothing]
289− cond = JSApp Nothing (JSAccessor Nothing "hasOwnProperty" obj) [jsKey]
290− assign = JSBlock Nothing [JSAssignment Nothing (JSIndexer Nothing jsKey jsNewObj) (JSIndexer Nothing jsKey obj)]
291− stToAssign (s, js) = JSAssignment Nothing (JSAccessor Nothing s jsNewObj) js
291+ copy = JSForIn Nothing key jsEvaluatedObj $ JSBlock Nothing [JSIfElse Nothing cond assign Nothing]
292+ cond = JSApp Nothing (JSAccessor Nothing "hasOwnProperty" jsEvaluatedObj) [jsKey]
293+ assign = JSBlock Nothing [JSAssignment Nothing (JSIndexer Nothing jsKey jsNewObj) (JSIndexer Nothing jsKey jsEvaluatedObj)]
294+ stToAssign (s, js) = JSAssignment Nothing (accessorString s jsNewObj) js
292295 extend = map stToAssign sts
293296 return $ JSApp Nothing (JSFunction Nothing Nothing [] block) []
294297