emojicode / emojicode

πŸ˜€πŸ˜œπŸ”‚ World’s only programming language that’s bursting with emojis

Home Page:https://emojicode.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

commented

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!