Syntax error with `using EllipsisNotation: .. as foo`

Is there some way to import .. from a package using as?

julia> using EllipsisNotation: .. as foo
ERROR: syntax: extra token "foo" after end of expression
Stacktrace:
 [1] top-level scope
   @ none:1

julia> using EllipsisNotation: :.. as foo
ERROR: syntax: invalid "using" statement: expected identifier
Stacktrace:
 [1] top-level scope
   @ none:1

julia> using EllipsisNotation: :(..) as foo
ERROR: syntax: invalid "using" statement: expected identifier
Stacktrace:
 [1] top-level scope
   @ none:1

The problem seems to be that the dots have a special meaning when parsed in using:

julia> :(using EllipsisNotation: .. as)
:(using EllipsisNotation: ..as)

I can manually construct the expression I want, although it’s interesting that its printed representation is not syntactically valid:

julia> expr = :(using EllipsisNotation: XYZ as foo)
:(using EllipsisNotation: XYZ as foo)

julia> expr.args[1].args[2].args[1].args[1] = :..
:..

julia> expr
:(using EllipsisNotation: .. as foo)

I guess I could do eval(expr), but is there a proper a way to write this?

1 Like

const foo = EllipsisNotation.:(..) after import EllipsisNotation might do it?

1 Like

Hm, I guess that should have the same effect. I was mostly asking out of curiosity, and thinking from a language point of view that there should be a way to use the syntax for all valid identifiers.

It does seem like you found a parser bug that’s worth reporting.

1 Like

Opened #49108!

1 Like