JuliaLang / julia

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

Confusing error with parametric type typo #23515

Open jebej opened 7 years ago

jebej commented 7 years ago

Misusing type assertions in a type declaration results in a confusing error about the where syntax:

julia> struct ContinuousShift{s::Real} end
ERROR: syntax: invalid variable expression in "where"
rfourquet commented 7 years ago

By the way, wouldn't it be possible to allow this syntax, for when the type parameter is not meant to be a type?

ckoe-bccms commented 6 years ago

This appears to be very similar: julia> function pp{::Float64}() end ERROR: syntax: invalid variable expression in "where" At least I find the error message as confusing.

MattKraemerNZ commented 6 years ago

Using '<' instead of '<:' in parameterized types yields the same error.

function f{T<Signed}(x::Array{T,1}) end ERROR: syntax: invalid variable expression in "where"

LilithHafner commented 2 years ago

Bump, this is still very confusing.

struct Wrapper{Vector{A}}
    data::A
end

LoadError: syntax: invalid variable expression in "where" around...