-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
The bug is caused by the parsing algorithm in src/grift/syntax->grift0.rkt.
For example, consider the following Grift program
(let ([a 1])
(+ a 2))
The syntax->grift0 will give the following AST:
(Prog
'("bad-let-2.grift" 1)
(list
(Ann2
(Observe
(Ann
(Let
(list
(Bnd
(Uid "a" 0)
#f
(Ann (Quote 1) (srcloc "bad-let-2.grift" 1 9 10 1))))
(Ann
(Op
'+
(list
(Ann (Var (Uid "a" 0)) (srcloc "bad-let-2.grift" 2 5 19 1))
(Ann (Quote 2) (srcloc "bad-let-2.grift" 2 7 21 1))))
(srcloc "bad-let-2.grift" 1 0 1 23)))
(srcloc "bad-let-2.grift" 1 0 1 23))
#f)
(srcloc "bad-let-2.grift" 1 0 1 23))))
The problem is that, the srcloc for (let ([a 1]) (+ a 2)) is exactly the srcloc for (+ a 2). Both of them are (1 0 1 1 23).
In general, the description of this bug is: if let or let-rec only has one expression in its body, then the srcloc of this expression will be the same as the outer let or let-rec.
I believe that is because of the weird logic of parse-begin. It seems that when the body of (begin e) only has one expression, this parsing algorithm will omit the outer begin. And all let, let-rec, define transform their bodies into a begin.
Metadata
Metadata
Assignees
Labels
No labels