mirror of
https://github.com/carp-lang/Carp.git
synced 2024-10-15 22:48:33 +03:00
Forcing evaluation of some expressions to detect multiple uses of variable in while loops.
This commit is contained in:
parent
6a310844d5
commit
fb41915876
@ -3,7 +3,6 @@
|
||||
## Critical Bugs
|
||||
* Ensure 'Array.pop-back' is memory safe and shrinks the array properly.
|
||||
* Can't define globals of with heap allocated types (String, structs, etc.)
|
||||
* Looping over a block of code where an external array is endo-map:ed over.
|
||||
* Arrays can contain references, this will lead to dangling pointers.
|
||||
|
||||
## Ugliness
|
||||
|
@ -1,2 +1,6 @@
|
||||
;; This file contains examples of unsolved bugs
|
||||
|
||||
(defn main []
|
||||
(let [stuff [@"a" @"b" @"c"]]
|
||||
(while true
|
||||
(Array.delete stuff))))
|
||||
|
@ -144,12 +144,14 @@ manageMemory typeEnv globalEnv root =
|
||||
manage body
|
||||
postDeleters <- get
|
||||
-- Visit an extra time to simulate repeated use
|
||||
_ <- visit expr
|
||||
_ <- visit body
|
||||
visitedExpr2 <- visit expr
|
||||
visitedBody2 <- visit body
|
||||
let diff = postDeleters Set.\\ preDeleters
|
||||
put (postDeleters Set.\\ diff) -- Same as just pre deleters, right?!
|
||||
return $ do okExpr <- visitedExpr
|
||||
okBody <- visitedBody
|
||||
okExpr2 <- visitedExpr2 -- This evaluates the second visit so that it actually produces the error
|
||||
okBody2 <- visitedBody2 -- And this one too. Laziness FTW.
|
||||
let newInfo = setDeletersOnInfo i diff
|
||||
return (XObj (Lst (whileExpr : okExpr : okBody : [])) newInfo t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user