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

Parsing f."a" causes a "malformed-expression" error with include #26873

Closed
tshort opened this issue Apr 21, 2018 · 2 comments · Fixed by #26878
Closed

Parsing f."a" causes a "malformed-expression" error with include #26873

tshort opened this issue Apr 21, 2018 · 2 comments · Fixed by #26878
Assignees
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage)

Comments

@tshort
Copy link
Contributor

tshort commented Apr 21, 2018

The syntax f."a" parses fine at the REPL, but it fails when the code is loaded with include:

julia> open(io->println(io, """f."a" """), "bug.jl", "w")

julia> include("bug.jl")
ERROR: LoadError: syntax: malformed expression
Stacktrace:
 [1] include at ./boot.jl:314 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1067
 [3] include(::Module, ::String) at ./sysimg.jl:29
 [4] include(::String) at ./sysimg.jl:68
 [5] top-level scope
in expression starting at /home/tshort/FS/appfiles/julia/MDPad/bug.jl:1

julia> f."a"
ERROR: UndefVarError: f not defined

Hyperscript uses this syntax. See the the bug report here: JuliaWeb/Hyperscript.jl#7.

Note that the error doesn't occur with f.`a` .

@KristofferC
Copy link
Member

Dup of #26739?

@tshort
Copy link
Contributor Author

tshort commented Apr 21, 2018

It may be the same root cause as #26739, but the symptoms look different to me. The syntax works at the REPL but not with include.

julia> f() = 1
f (generic function with 1 method)

julia> Base.getproperty(::typeof(f), ::String) = "Hello"

julia> f."a"
"Hello"

julia> open(io->println(io, """f."a" """), "bug.jl", "w")

julia> include("bug.jl")
ERROR: LoadError: syntax: malformed expression
Stacktrace:
 [1] include at ./boot.jl:314 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1067
 [3] include(::Module, ::String) at ./sysimg.jl:29
 [4] include(::String) at ./sysimg.jl:68
 [5] top-level scope
in expression starting at /home/tshort/FS/appfiles/julia/MDPad/bug.jl:1

@JeffBezanson JeffBezanson self-assigned this Apr 21, 2018
@JeffBezanson JeffBezanson added the compiler:lowering Syntax lowering (compiler front end, 2nd stage) label Apr 21, 2018
JeffBezanson added a commit that referenced this issue Apr 21, 2018
fix #26739, error for `sum.[1]`
fix #26873, should have no error for `f."a"`
JeffBezanson added a commit that referenced this issue Apr 23, 2018
fix #26739, error for `sum.[1]`
fix #26873, should have no error for `f."a"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants