Julia: Export commands do not give errors when you miss commas

Created on 5 Dec 2019  路  12Comments  路  Source: JuliaLang/julia

If you do

include("file.jl")
export
   test
   test1

it doesn't give an error but it doesn't export the 2nd function. This seems weird to me.

All 12 comments

Thus is valid syntax and this kind of issue is the best for a linter.

Why is this valid syntax? That鈥檚 my point; Maybe it shouldn鈥檛 be valid.

It's valid syntax because test1 is valid syntax. I can't check right now but I think if you put everything on the same line it will be an error.

Yichao is right. You can't even finish a module definition at the REPL with this syntax before encountering an error:

julia> module M
       export a b
ERROR: syntax: extra token "b" after end of expression
Stacktrace:
 [1] top-level scope at REPL[6]:0

right but

module M
       export 
          a 
          b

is valid

even though b is not actually exported

Right, you're evaluating b on a line by itself. Not sure there's anything we can do about this.

I am just making things up that may not be possible but why not just do something under the hood to evaluate the exports on the same line

julia> module M
       export a,b
       end
Main.M

julia> module M
       export a b
       end
ERROR: syntax: extra token "b" after end of expression
Stacktrace:
 [1] top-level scope at REPL[2]:0

that way if there's a missing comma it errors out rather than acts as if all is well

export a
b

already means something: it means export a; b 鈥斅爄t exports a and then evaluates b.

Got it. Just wanted to voice my thought. Thanks for the feedback/time!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dpsanders picture dpsanders  路  3Comments

omus picture omus  路  3Comments

manor picture manor  路  3Comments

StefanKarpinski picture StefanKarpinski  路  3Comments

sbromberger picture sbromberger  路  3Comments