Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify error on all-underscore field name that isn't _. #37381

Open
goretkin opened this issue Sep 3, 2020 · 1 comment
Open

Clarify error on all-underscore field name that isn't _. #37381

goretkin opened this issue Sep 3, 2020 · 1 comment

Comments

@goretkin
Copy link
Contributor

goretkin commented Sep 3, 2020

julia> struct Good{T}
       _::T
       end

# (no error)

julia> struct Bad{T}
       __::T
       end
ERROR: syntax: all-underscore identifier used as rvalue

For what it's worth, I like this behavior. I just think the error message should be improved since, 1. it doesn't seem like an rvalue to me (maybe that's my fault, but see below), and 2. you can have an all-underscore field name so long as it's _.

Regarding the term rvalue:

julia> mutable struct GoodM{T}
       _::T
       end

julia> GoodM(1)
GoodM{Int64}(1)

julia> GoodM(1)._
1

julia> GoodM(1)._ = 3 # feels like it's an lvalue!
3
@kimikage
Copy link
Contributor

kimikage commented Sep 4, 2020

cf. #36865

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants