JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.43k stars 5.45k forks source link

`3:::Int` parses as `3::(:Int)` #55304

Open nsajko opened 1 month ago

nsajko commented 1 month ago
julia> 3:::Int
ERROR: TypeError: in typeassert, expected Type, got a value of type Symbol
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

julia> 3::(:Int)
ERROR: TypeError: in typeassert, expected Type, got a value of type Symbol

Perhaps a warning/syntax error would make more sense.

JeffBezanson commented 1 month ago

Works perfectly:

julia> @eval 3:::($Int)
3

:smile:

nsajko commented 1 month ago

The reason this bothers me, sorry for not being clear before, is that ::: instead of :: is an easy typo to make.

LilithHafner commented 1 month ago

How do you propose it should parse?

nsajko commented 1 month ago

Sorry for not being clear, I propose the syntax should be disallowed in one of the strict modes, xref #54903

nsajko commented 1 month ago

So, instead of @eval 3:::($Int), one would have to write @eval 3 :: :($Int) or @eval 3::(:($Int)).