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

"verbose-errors" changes nom's API #843

Closed
jsgf opened this issue Oct 12, 2018 · 3 comments
Closed

"verbose-errors" changes nom's API #843

jsgf opened this issue Oct 12, 2018 · 3 comments
Milestone

Comments

@jsgf
Copy link
Contributor

jsgf commented Oct 12, 2018

Prerequisites

Here are a few things you should provide to help me understand the issue:

  • Rust version : 1.29.0
  • nom version : 3.2.1
  • nom compilation features used:

The verbose-errors feature changes nom's API by changing the definition of the IResult type in a non-compatible way. This means that enabling the feature will break downstream users which don't expect it.

Since cargo always accumulates features across the dependency graph, if there are two users of nom within the same dep graph, and one enabled verbose-errors, it will break the other user which doesn't want it.

This is because in general cargo expects features to extend the functionality of a crate in a compatible way.

It would be better to make the verbose- and simple- explicit separate parts of the exposed API so that you can just use the API you want from a single instance of the crate.

cc: @alexcrichton

@Geal
Copy link
Collaborator

Geal commented Oct 13, 2018

hello,

there's a workaround in nom 4: the errors are now an enum, and the one from verbose-errors includes the only case from simple-errors.

@kryptan
Copy link

kryptan commented Nov 15, 2018

@Geal, what do you mean by workaround? How do I actually handle the error in a way that won't break if verbose-errors is enabled?

match context {
    Context::Code(input, error) => { ... },
    _ => unreachable!(),
}

This generates a warning about unreachable pattern and would panic if verbose-errors is enabled and other variant is returned.

Can you please provide an example how to handle the error properly?

@Geal Geal added this to the 5.0 milestone Dec 14, 2018
alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Mar 12, 2019
This commit works around rust-bakery/nom#843 where the API of the `nom` crate
changes based on feature selection, meaning we need to be compatible
even if another crate in the crate graph enables a feature.

Ideally this'd be fixed in upstream `nom`, and it looks like it will in
the next major version! For now a local catch-all directive should help
out.
@Geal
Copy link
Collaborator

Geal commented May 1, 2019

verbose-errors has disappeared in nom 5. Now the error behaviour is completely decided by the error type

@Geal Geal closed this as completed May 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants