Julia: trailing : can lead to unexpected parse results

Created on 14 Jun 2016  路  7Comments  路  Source: JuliaLang/julia

Reading http://docs.julialang.org/en/release-0.4/manual/running-external-programs/ for reference, I was surprised to find that this doesn't work. And it seems like a bug to me:

function runls():
    run(`ls`)
end
runls()
LoadError: MethodError: `call` has no method matching call(::Symbol, ::Cmd)
Closest candidates are:
  BoundsError()
  BoundsError(!Matched::Any...)
  DivideError()
  ...
while loading In[34], in expression starting on line 4

 in runls at In[34]:2
bug parser speculative

Most helpful comment

The parser should probably give a better error here.

All 7 comments

Maybe the syntax error for a trailing : at the end of a line should be extended to include quoting expressions?

Is there an obvious workaround for this?

Delete the :

Oh, that's an embarrassing bug report on my part.

The parser should probably give a better error here.

@dmyersturnbull funnily enough, I'm also coming from Python and have committed this exact error several times. I agree that the parser should give a better error for this case.

The parser should probably give a better error here.

I assume you mean the parser should give an error here since this is currently parsed as valid syntax. Given that https://github.com/JuliaLang/julia/issues/15173 was closed due to more explicit errors for python syntax, I agree we should deprecate quoting syntax that spawn multiple lines (or even with with white space after the :) and make it an error later.

Was this page helpful?
0 / 5 - 0 ratings