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

dep bug (v1.5.0 CLI): jison 0.4.17 broke API in a minor release #900

Closed
summivox opened this issue Jun 8, 2016 · 4 comments
Closed

dep bug (v1.5.0 CLI): jison 0.4.17 broke API in a minor release #900

summivox opened this issue Jun 8, 2016 · 4 comments

Comments

@summivox
Copy link
Contributor

summivox commented Jun 8, 2016

write file a.ls:

if
else
  ...

run in shell:

lsc -cw *.ls

results in:

Failed at: a.ls
C:\Users\summi\AppData\Roaming\npm\node_modules\livescript\lib\command.js:260
            warn(e + '\x07');
                   ^

TypeError: Function.prototype.toString is not generic
    at compileScript (C:\Users\summi\AppData\Roaming\npm\node_modules\livescript\lib\command.js:260:20)
    at C:\Users\summi\AppData\Roaming\npm\node_modules\livescript\lib\command.js:152:11
    at C:\Users\summi\AppData\Roaming\npm\node_modules\livescript\lib\command.js:142:7
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:439:3)

Turns out:

diff --git a/lib/parser.js b/lib/parser.js
index bba7afc..4cf0e84 100644
--- a/lib/parser.js
+++ b/lib/parser.js
@@ -1,4 +1,4 @@
-/* parser generated by jison 0.4.15 */
+/* parser generated by jison 0.4.17 */
 /*
   Returns a Parser object of the following structure:

@@ -781,7 +781,13 @@ parseError: function parseError(str, hash) {
     if (hash.recoverable) {
         this.trace(str);
     } else {
-        throw new Error(str);
+        function _parseError (msg, hash) {
+            this.message = msg;
+            this.hash = hash;
+        }
+        _parseError.prototype = Error;
+
+        throw new _parseError(str, hash);
     }
 },

Noticed the noob line yet?

        _parseError.prototype = Error;

Yikes, new _parseError is a Function. This is... sort of okay (while unintended) until in command.ls:

  catch then if e?
    if LiveScript.listeners 'failure' .length
      LiveScript.emit 'failure' e, t
    else
      warn "Failed at: #filename" if filename
      unless e instanceof SyntaxError or /^Parse error /test e.message
        e = e.stack or e
      if o.watch then warn e + '\7'
                 else die  e
    return

Unfortunately node.js as of now does not allow coercion of a Function (e here) to string (e + '\7').

Suggestion:

  1. pin down jison version for now
  2. notify them of this bug
  3. maybe use e.message + '\7' for now
@summivox
Copy link
Contributor Author

summivox commented Jun 8, 2016

Edit: Seems that someone already filed this bug in jison:

zaach/jison#328

@vendethiel
Copy link
Contributor

this should be reopened, the bug still happens regularly when using -cw

@rhendric
Copy link
Collaborator

Repro, @vendethiel? I can't reproduce with the original report.

@vendethiel
Copy link
Contributor

I patched it locally. I'll have to remove the patch and check next time, but pretty much everytime I write invalid code I get this behavior.

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