-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
improve error message for missing return type #1672
Comments
I actually think we should disallow return type expressions starting with Here's the real question: why would you ever want a return expression to legitimately begin with |
I would make this a priority... It's something that newcomers are going to run into again and again. (As well as people who frequently switch between Zig and another language like JS.) The error message still initially confuses me after the tenth time running into it. And if there was a reason to allow return types to start with For me, this issue ranks right up there with the 'copying fieldParentPtr thing out of a struct' footgun. |
I too run frequently forget the return type and stumble into this all the
time. So I look forward to seeing a better error message.
…On Sun, Oct 21, 2018, 10:46 AM dbandstra ***@***.***> wrote:
I would make this a priority... It's something that newcomers are going to
run into again and again. (As well as people who frequently switch between
Zig and another language like JS.) The error message still initially
confuses me after the tenth time running into it.
And if there was a reason to allow return types to start with {, I think
it would be worth adding a new symbol to the syntax introducing the return
type.
For me, this issue ranks right up there with the 'copying fieldParentPtr
thing out of a struct' footgun.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1672 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA-hHCIA4Oys6VVoi-tPAJ2Um7NRba89ks5unLLtgaJpZM4XyJ31>
.
|
@thejoshwolfe i think we're talking about two different things here. i'm talking about the error message you get from code like this:
|
@emekoi that is what I'm talking about too. Once the parser sees: fn foo() { there's no possible way that the program could compile successfully. We can have the parser report an error pointing to that |
After #1685 we now get this error:
Not perfect, but we get the error earlier, which should help alot. |
I would consider this solved, with a low priority further improvement being to special case this error and add something like "expected return type" |
with Zig master this now works as expected pub fn main() {
}
|
when the return type is missing for a function, i get the error
expected token '{', found 'fn'
. could someone point me towards the code that handles parsing of functions, so i could fix this?The text was updated successfully, but these errors were encountered: