Segfault & bad error message in splices #1272

Closed
pao opened this Issue Sep 11, 2012 · 4 comments

Comments

Projects
None yet
4 participants
Member

pao commented Sep 11, 2012

Clearly, the $ prefix is well within the quote block (this is missing parens, though). Then there's the segfault.

julia> test(x) = quote
           $x($x)
       end

julia> test(:())
syntax error: prefix $ outside of quote block

julia> test(:())
syntax error: prefix $ outside of quote block

julia> test(:())
Segmentation fault (core dumped)
Member

pao commented Sep 11, 2012

I can actually get the segfault if this happens to be the right error message, too.

julia> test(x) = $x

julia> test(:())
syntax error: prefix $ outside of quote block

julia> test(:())
syntax error: prefix $ outside of quote block

julia> test(:())
Segmentation fault (core dumped)
Member

toivoh commented Sep 11, 2012

@pao: The second $ is actually outside the quote block. Your example is equivalent to

julia> test(x) = quote
           $(x($x))
       end

since interpolation in expressions is greedy. Interpolation (tries to) evaluate the argument x($x) outside of the quote block, and then use the result in building the AST.

Owner

StefanKarpinski commented Sep 11, 2012

Greedy splicing strikes again.

Member

pao commented Sep 11, 2012

Sure--I did say it was missing parens--but nothing in the error message indicates that that's what's going on, which was my point. There's two $'s in that expression, and both of them are contained in the quote block. Not knowing which one is wrong, or why, is why the error message is bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment