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

0 becomes null #2

Open
erjiang opened this issue Jan 22, 2021 · 1 comment
Open

0 becomes null #2

erjiang opened this issue Jan 22, 2021 · 1 comment

Comments

@erjiang
Copy link

erjiang commented Jan 22, 2021

On pasukon.rocks, with the example grammar, type in 0 for the input. The result comes back as null, not 0. I've also written a test for this that I think demos the issue: erjiang@d9a6104

@erjiang
Copy link
Author

erjiang commented Jan 23, 2021

This patch seems to work (tests pass, at least):

--- a/lib/parsers/result.js
+++ b/lib/parsers/result.js
@@ -4,7 +4,7 @@ module.exports = class Result {
   constructor ({ success, remaining, matched }) {
     this.success = success
     this.remaining = remaining
-    this.matched = matched || null
+    this.matched = matched == null ? null : matched
   }
 
   get failed () {

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

1 participant