Comparing Enumerations across package boundary behaves weird.
nathanmentley opened this issue Β· comments
I apologize if my misunderstanding is causing a false bug report.
I'm working on a simple cli library: (https://github.com/nathanmentley/emoji-cli)
Semi similar to an overly simplified clone the golang library Cobra (https://github.com/spf13/cobra)
In my package I'm defining this enum for error codes:
π β enum <- A collection of error codes. π
π π¦ β π
ππ€¦ π Couldn't execute a command
ππ π No command passed
ππ π Missing Required Parameter
π
If I throw βπ in my library package
I'm able to catch it and correctly compare it to see the correct error message when doing the compare in the package:
π π π π
...
π βοΈ β error β π
ππ€An error occurred.π€βοΈ
βͺοΈ error π πβπ€¦βοΈ π
ππ€For an unknown reason the command could not be executed.π€βοΈ
π
βͺοΈ error π πβπβοΈ π
ππ€Command not found.π€βοΈ
π
βͺοΈ error π πβπβοΈ π
ππ€A required parameter is missing from the command. See help for more details.π€βοΈ
π
π
π
π¦ clihelper π
π β‘οΈ π’ π
π Build app object.
π πΆππ πβοΈ β‘οΈ app
...
π Execute the app.
π₯ ret π app βοΈ π
β©οΈ ret
π
π
error π
π Optionally use the built in error handling.
β app error βοΈ
β©οΈ -1
π
π
But if I do the compare outside of the package:
π¦ clihelper π
π β‘οΈ π’ π
...
π Execute the app.
π₯ ret π app βοΈ π
β©οΈ ret
π
π
error π
π Use custom error handling
βͺοΈ error π ππΆπβπ€¦βοΈ π
ππ€For an unknown reason the command could not be executed.π€βοΈ
π
βͺοΈ error π ππΆπβπβοΈ π
ππ€Command not found.π€βοΈ
π
βͺοΈ error π ππΆπβπβοΈ π
ππ€A required parameter is missing from the command. See help for more details.π€βοΈ
π
β©οΈ -1
π
π
The wrong error error message display. Because βπ ππΆπβπ€¦ is evaluating to true.
I have a fork of the emojicode repo. I'd be willing to hack on it and make a pull request if this is in fact a bug. I just want to make sure I'm not misunderstanding something here.
Thanks.
You can see this issue in action by in the example/bug-report-emojicode-issue-123 branch of this repo: https://github.com/nathanmentley/emoji-cli/
Once cloned you can run:
yarn example echo -e "test message"
to see the example project running correctly
running:
yarn example echo
I'd expect it to print the "A required parameter is missing from the command. See help for more details." message, but instead it prints the wrong message "For an unknown reason the command could not be executed."
If you checkout the master branch of that repo it does this error handling / message printing inside the library package and works correctly.
The issue was caused by a bug in the Prettyprinter, which is also responsible for generating the interface file. Moreover, your package caused a flow control bug to surface, which was also the reason for any LLVM warnings, you might have seen.
Very interesting project, by the way!