Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolated getproperty syntax error #426

Open
dennisYatunin opened this issue Mar 18, 2024 · 1 comment
Open

Interpolated getproperty syntax error #426

dennisYatunin opened this issue Mar 18, 2024 · 1 comment

Comments

@dennisYatunin
Copy link

dennisYatunin commented Mar 18, 2024

I am seeing the following unexpected behavior with Julia version 1.10.2:

julia> foo(x) = x.:($(1 + 2)) + 0
ERROR: syntax: invalid syntax "x.((1 + 2))" around REPL[1]:1
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1

julia> foo(x) = x.:($(1 + 2)) += 0
ERROR: syntax: invalid syntax "x.(SSAValue(9))" around REPL[2]:1
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

julia> foo(x) = x.:($(1 + 2)) .+= 0
ERROR: syntax: invalid syntax "x.(SSAValue(16))" around REPL[3]:1
Stacktrace:
 [1] top-level scope
   @ REPL[3]:1

julia> foo(x) = x.:($(1 + 2)) .= 0
foo (generic function with 1 method)

All of these definitions work when they are written out as calls to getproperty, so it looks like this is hitting some uncaught edge case for expression interpolation.

@c42f
Copy link
Member

c42f commented Jul 17, 2024

This error arises from lowering, it's not really a JuliaSyntax issue:

julia> (101im).:($(:im))
101

julia> (101im).:($(Symbol("im")))
ERROR: syntax: invalid syntax "(101 * im).(Symbol("im"))" around REPL[25]:1
Stacktrace:
 [1] top-level scope
   @ REPL[25]:1

# and yet this parses fine:
julia> :((101im).:($(Symbol("im"))))
:((101im).:($(Expr(:$, :(Symbol("im"))))))

The fact that x.:($y) works at all, in any cases, might just be a mistake? I'm not sure. getproperty(x,y) seems a lot better to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants