-
Notifications
You must be signed in to change notification settings - Fork 996
compileopts: improve error reporting of unsupported flags #1073
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
compileopts: improve error reporting of unsupported flags #1073
Conversation
1062 - Called Options.Validate method in main
compileopts/options.go
Outdated
|
|
||
| var ( | ||
| validGCOptions = []string{"none", "leaking", "extalloc", "conservative"} | ||
| validSchedulerOptions = []string{"tasks", "coroutines"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"none" is also a valid scheduler option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaddr2line oh I see.. so I think I should also modify this line https://github.com/tinygo-org/tinygo/blob/master/main.go#L713 and this line: https://github.com/tinygo-org/tinygo/blob/master/compileopts/config.go#L132
can you please confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes those should be updated. You could add it to this PR: even though it's somewhat separate it's a small and obvious fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaddr2line @aykevl done!
compileopts/options.go
Outdated
| // ErrSchedulerInvalidOption is an error raised if scheduler option is not valid | ||
| ErrSchedulerInvalidOption = fmt.Errorf(`invalid scheduler option: valid values are %s`, | ||
| strings.Join(validSchedulerOptions, ", ")) | ||
| //ErrPrintSizeInvalidOption is an error raised if size option is not valid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a space before the first word in a doc comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
main.go
Outdated
| Programmer: *programmer, | ||
| } | ||
|
|
||
| err := options.Verify() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure whether this is the right place to put this, as we continue modifying the options after this.
What do you think @aykevl ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this doubt as well, I put it here because it looked to me that after this line nothing was setting GC, Scheduler or PrintSize.. very curious to see what's you thoughts are..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it should be done when the options object is finished building and won't be modified anymore.
Looking down below I see that there is also a custom check for panicStrategy. I think it would make sense to move that one to the common Verify function too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aykevl I moved panicStrategy check under options as well, and removed it from main.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aykevl @jaddr2line I've also moved options.Validate call later in the code..
I'm still unsure about it, because a few lines later, in the "build" case of the switch, options.Target is modified.
Another option could be moving the option check into builder.NewConfig...
what do you guys think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aykevl @jaddr2line what do you think about moving the options.Verify block into builder.NewConfig?
The more I think about it, the more it looks to me the right place 🤔
|
The macos build failure appears to have been caused by a partial CircleCI outage, which has since been fixed. |
…rated options list from the errors
Co-Authored-By: Jaden Weiss <[email protected]>
Co-Authored-By: Jaden Weiss <[email protected]>
…ygo into 1062-flag-error-reporting
|
I think the current I think this PR is fine as it is right now and could be squashed/merged. If I were to suggest any changes, it would be the following:
|
|
@aykevl probably I didn't explain myself, I apologies for this. builder.NewConfig takes an Option parameter, so I thought it was a good spot. Regarding your other suggestions, no problem, I'll change the error generation to include the offending value 👍 |
|
@aykevl I've unexported the errors (actually, I got rid of them at all) and included the incorrect option value in the message. |
aykevl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thank you for the updates!
|
Oops I didn't pay attention and I accidentally merged this into master. It should be fixed now. |
PR for #1062