felipeochoa / rjsx-mode

A JSX major mode for Emacs
https://github.com/felipeochoa/rjsx-mode
MIT License
641 stars 32 forks source link

Parse error #77

Closed fxfactorial closed 6 years ago

fxfactorial commented 6 years ago

Getting this error on latest rjsx

Error running timer ‘js2-mode-idle-reparse’: (wrong-type-argument js2-node [cl-struct-rjsx-identifier 60 1573 3 nil nil nil #s(js2-name-node 39 1573 3 nil nil "div" nil)]) 
felipeochoa commented 6 years ago

What are your emacs version, rjsx version, js2-version, file contents?

fxfactorial commented 6 years ago

What are quick ways to find rjsx version? I don't know if I can share file content, depends what part of file it is.

felipeochoa commented 6 years ago

M-x package-list-package and look for rjsx.

Without the entire file contents I probably won't be able to debug. I'd suggest trying to reproduce with a smaller file first

fxfactorial commented 6 years ago

20180624.1758 installed for rjsx

REMOVED CAUSE PROP CODE

Can you tell me when you have copy pasted it so I can delete from here.

felipeochoa commented 6 years ago

rjsx does not support flow types. If you take those out does it solve the problem?

fxfactorial commented 6 years ago

its fine with other flow files, removing flow still causes same error

felipeochoa commented 6 years ago

What's your emacs version and js2 version?

fxfactorial commented 6 years ago

emacs: emacs: 26.1-2 via brew cask install emacs js2: 20180627.744

felipeochoa commented 6 years ago

Ok. I don't have 26 handy to debug. Can you (after deleting the flow types) enable debug on error and post the backtrace?

fxfactorial commented 6 years ago
Debugger entered--Lisp error: (wrong-type-argument js2-node #s(rjsx-identifier :type 60 :pos 1727 :len 3 :props nil :parent nil :namespace nil :name #s(js2-name-node :type 39 :pos 1727 :len 3 :props nil :parent nil :name "div" :scope nil)))
  signal(wrong-type-argument (js2-node #s(rjsx-identifier :type 60 :pos 1727 :len 3 :props nil :parent nil :namespace nil :name #s(js2-name-node :type 39 :pos 1727 :len 3 :props nil :parent nil :name "div" :scope nil))))
  js2-fixup-starts(#s(rjsx-identifier :type 60 :pos 1727 :len 3 :props nil :parent nil :namespace nil :name #s(js2-name-node :type 39 :pos 1727 :len 3 :props nil :parent nil :name "div" :scope nil)) (#s(js2-name-node :type 39 :pos 1727 :len 3 :props nil :parent nil :name "div" :scope nil)))
  js2-node-add-children(#s(rjsx-identifier :type 60 :pos 1727 :len 3 :props nil :parent nil :namespace nil :name #s(js2-name-node :type 39 :pos 1727 :len 3 :props nil :parent nil :name "div" :scope nil)) #s(js2-name-node :type 39 :pos 1727 :len 3 :props nil :parent nil :name "div" :scope nil))
  rjsx-parse-identifier(rjsx-tag)
  rjsx-parse-member-or-ns(rjsx-tag)
  rjsx-parse-xml()
  rjsx-parse-top-xml()
  rjsx-parse-xml-initializer(#f(compiled-function () #<bytecode 0x412f5789>))
  apply(rjsx-parse-xml-initializer #f(compiled-function () #<bytecode 0x412f5789>) nil)
  js2-parse-xml-initializer()
  js2-parse-unary-expr()
  js2-parse-expon-expr()
  js2-parse-mul-expr()
  js2-parse-add-expr()
  js2-parse-shift-expr()
  js2-parse-rel-expr()
  js2-parse-eq-expr()
  js2-parse-bit-and-expr()
  js2-parse-bit-xor-expr()
  js2-parse-bit-or-expr()
  js2-parse-and-expr()
  js2-parse-or-expr()
  js2-parse-cond-expr()
  js2-parse-assign-expr()
  js2-parse-expr()
  js2-parse-paren-expr-or-generator-comp()
  js2-parse-primary-expr()
  js2-parse-member-expr(t)
  js2-parse-unary-expr()
  js2-parse-expon-expr()
  js2-parse-mul-expr()
  js2-parse-add-expr()
  js2-parse-shift-expr()
  js2-parse-rel-expr()
  js2-parse-eq-expr()
  js2-parse-bit-and-expr()
  js2-parse-bit-xor-expr()
  js2-parse-bit-or-expr()
  js2-parse-and-expr()
  js2-parse-or-expr()
  js2-parse-cond-expr()
  js2-parse-assign-expr()
  js2-parse-expr()
  js2-parse-return-or-yield(4 nil)
  js2-parse-ret-yield()
  js2-statement-helper()
  js2-parse-statement()
  js2-parse-function-body(#s(js2-function-node :type 108 :pos 1696 :len 1 :props nil :parent nil :kids nil :symbol-table nil :parent-scope nil :top nil :functions nil :regexps nil :symbols nil :param-count 0 :var-names nil :consts nil :temp-number 0 :ftype FUNCTION :form FUNCTION_EXPRESSION :name nil :params nil :rest-p nil :body nil :lp 6 :rp 7 :ignore-dynamic nil :needs-activation nil :generator-type nil :async nil :member-expr nil))
  js2-parse-function-internal(FUNCTION_EXPRESSION 1696 nil nil nil)
  js2-parse-function(FUNCTION_EXPRESSION 1696 nil nil nil)
  js2-parse-method-prop(nil #s(js2-name-node :type 39 :pos 1696 :len 6 :props nil :parent nil :name "render" :scope nil) nil)
  js2-parse-named-prop(39 nil t)
  js2-parse-object-literal-elems(t)
  js2-parse-class(967 CLASS_STATEMENT #s(js2-name-node :type 39 :pos 973 :len 3 :props nil :parent nil :name "App" :scope nil))
  js2-parse-class-stmt()
  js2-statement-helper()
  js2-parse-statement()
  js2-do-parse()
  js2-parse()
  js2-reparse()
  js2-mode-idle-reparse(#<buffer app.js>)
  apply(js2-mode-idle-reparse #<buffer app.js>)
  timer-event-handler([t 0 0 0 nil js2-mode-idle-reparse (#<buffer app.js>) idle 0])
bbenne10 commented 6 years ago

I'm seeing the same problem:

emacs version 26.1 rjsx version 20180314.845 js2 version 20180331.2247

Possibly related to this issue over at js2?

File contents on which I'm seeing this problem:

import React from 'react'
import ReactDOM from 'react-dom'

class App extends React.Component {
  render () {
    <div className='app' />
  }
}

ReactDOM.render(<App />, document.getElementById('root'))

if (module.hot) {
  module.hot.accept()
}

Seems like @fxfactorial has some problems with the privacy of the code they've posted. Since we can reproduce with mine above, I'd say he can delete his.

I'll be updating and checking for the same traceback here as soon as I post this.

EDITED TO NOTE that this also happens on a pre-release version of emacs 27, though I'm not sure how old that build really is.

bbenne10 commented 6 years ago

Oh. Interesting. I have updated both rjsx and js2, but it looks like the problem might be solved?

@fxfactorial: try to recompile the extensions. I forced this by simply deleting my ~/.emacs.d/elpa/{rjsx-*,js2-*}, which caused use-package to download the newer versions and build new byte-code.

fxfactorial commented 6 years ago

@bbenne10 yep, that solved it!

torgeir commented 6 years ago

That fixed it on my end as well!