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

Unintuitive error message caused by [*] #1897

Closed
matthew-mcallister opened this issue Jan 26, 2019 · 2 comments
Closed

Unintuitive error message caused by [*] #1897

matthew-mcallister opened this issue Jan 26, 2019 · 2 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. error message This issue points out an error message that is unhelpful and should be improved.
Milestone

Comments

@matthew-mcallister
Copy link
Contributor

matthew-mcallister commented Jan 26, 2019

On master, I tried using the wrong syntax for pointer dereferencing and got a surprising error message (similar in appearance to #401) on this minimal input:

zig[*zag]

Output:

/home/mattmcal/foo.zig:1:6: error: invalid character: 'z'
zig[*zag]
     ^

Obviously, the mistake is not my use of the letter 'z' but rather that I have a malformed expression.

@matthew-mcallister
Copy link
Contributor Author

matthew-mcallister commented Jan 27, 2019

So I fired up gdb and found out that [*] is treated as a single token by the tokenizer, which explains where the arrow location comes from. I guess this isn't a bug per se, the error message is just surprising. I suppose this suggests the need for better parsing error messages in the future, but I'm going to close this issue on the premise that it's probably a low-ish priority and merits a separate issue anyways.

EDIT: On second thought, I think it makes more sense to just leave the issue open to document the concern. Sry 'bout that.

@matthew-mcallister matthew-mcallister changed the title Incorrect error location on invalid character Unintuitive error message caused by [*] Jan 27, 2019
@andrewrk andrewrk added this to the 0.5.0 milestone Jan 28, 2019
@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Jan 28, 2019
@andrewrk
Copy link
Member

Thanks for the report! I agree that it's worth it to improve this error message.

@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Aug 21, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Oct 17, 2019
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 10, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@SpexGuy SpexGuy added the error message This issue points out an error message that is unhelpful and should be improved. label Apr 5, 2021
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
Vexu added a commit to Vexu/zig that referenced this issue Oct 28, 2022
@Vexu Vexu closed this as completed in 61f5ea4 Nov 4, 2022
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Nov 4, 2022
@andrewrk andrewrk modified the milestones: 0.11.0, 0.10.1 Jan 9, 2023
TUSF pushed a commit to TUSF/zig that referenced this issue May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. error message This issue points out an error message that is unhelpful and should be improved.
Projects
None yet
Development

No branches or pull requests

3 participants