Skip to content

Decide whether @... is intended to work #58892

@Keno

Description

@Keno

@. is a special parser form that lowers to @__dot__:

julia> :(@.)
:(#= REPL[4]:1 =# @__dot__)

julia> macro __dot__() 1 end
@__dot__ (macro with 1 method)

julia> @.
1

The parser also supports @.. because .. is an operator, which is allowed as a macro name:

julia> :(@+)
:(#= REPL[7]:1 =# @+)

julia> macro ..() 2 end
@.. (macro with 2 methods)

julia> @..
2

But what about ...? It parses in macro call context:

julia> :(@...)
:(#= REPL[13]:1 =# @var"...")

but defining it is an error:

julia> macro ...() 3 end
ERROR: ParseError:
# Error @ REPL[12]:1:7
macro ...() 3 end
#     └─┘ ── invalid identifier
Stacktrace:
 [1] top-level scope
   @ REPL:1

unless you use var:

julia> macro var"..."(args...) 3 end
@... (macro with 1 method)

julia> @...
3

Four dots and up parses as a macro call to @..., with normal dot parsing for the remaining arguments, but since it's mostly illegal, it's a bit confusing:

julia> (@....)
ERROR: ParseError:
# Error @ REPL[33]:1:7
(@....)
#     ╙ ── unexpected `)`
Stacktrace:
 [1] top-level scope
   @ REPL:1

julia> (@.....)
3

julia> (@......)
ERROR: ParseError:
# Error @ REPL[35]:1:6
(@......)
#    └─┘ ── invalid identifier
Stacktrace:
 [1] top-level scope
   @ REPL:1

julia> (@.......)
ERROR: ParseError:
# Error @ REPL[36]:1:6
(@.......)
#    └─┘ ── invalid identifier
Stacktrace:
 [1] top-level scope
   @ REPL:1

My preference would be to make @... an illegal identifier parse (and thus by implication also the four-dots-and up variants). I don't think this was ever intended to work and is just an artifact of how the parser treats ... currently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageThis should be discussed on a triage call

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions