Skip to content

TypeError: Cannot call method 'error' of undefined in 1.6.3, works fine in 1.6.2 #3053

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

Closed
eranation opened this issue Jun 27, 2013 · 20 comments

Comments

@eranation
Copy link

compiling with 1.6.3 breaks with the error as in the title, but the same code compiles in 1.6.2, I think it has something to do with 'own' in for loops. but not sure yet.

I reproduce it but my code base is too big (and a proprietary project) so I need to work on narrowing it down

But i found someone who managed to reproduce it that also included the code:
https://groups.google.com/forum/#!topic/coffeescript/qiUWkPBJ3gM

I will update this issue soon once I get a small enough piece of code to reproduce as well.

EDIT: of course I didn't even bother to check and see that the sample in the link is a js file (which explains the "And what's your coffee ?" comment by @Nami-Doc ) sorry about that! :)

@vendethiel
Copy link
Collaborator

the included sample is .js

@michaelficarra
Copy link
Collaborator

@michaelficarra
Copy link
Collaborator

Should lines 1840 and 1841 be @pattern.error and @own.error, respectively?

edit: never mind, that doesn't make any sense.

@vendethiel
Copy link
Collaborator

1841 is mine (b3ffd25) and I remember that @own.error obviously did not work (same error as here)

@michaelficarra
Copy link
Collaborator

Yeah, because it's a bool and doesn't have an error method. We just need to find out why an instance of Value doesn't have an error method.

@marchaefner
Copy link
Collaborator

@michaelficarra: You're off by one line. The stacktrace points at the change by @Nami-Doc.

It's easily reproducible:

$ coffee -e 'x for own x in l'
TypeError: Cannot call method 'error' of undefined
...

And it works as expected if an index is used:

$ coffee -e 'x for own x,i in l'
[stdin]:1:13: error: cannot use own with for-in
x for own x,i in l
            ^

I think it would be best to just use @error.

@vendethiel
Copy link
Collaborator

@error didn't work either, didn't looked further why.

@marchaefner
Copy link
Collaborator

@error didn't work either, didn't looked further why.

Ah yes, For gets its locationData only after instantiation.

@name.error would then be the next best thing. @name is always defined if own is used (and it works - i tested it this time).

@michaelficarra
Copy link
Collaborator

The error is on in, so that keyword should be highlighted.

@sferik
Copy link

sferik commented Jul 12, 2013

I'm seeing this regression as well. I can confirm that downgrading to version 1.6.2 fixes the issue.

@gottfrois
Copy link

+1 for the error. Had to downgrade to 1.6.2

@vendethiel
Copy link
Collaborator

I have a commit fixing that (870a940) but I'd rather not have a solution so hacky.

@nathanpalmer
Copy link

+1 for this error. Just downgraded to 1.6.2. We have "for own property in result" in our code that is triggering it.

@marchaefner
Copy link
Collaborator

A less hacky (but also less user-friendly) solution would be to just not parse the offending code (see 91b2cf6) which would look like this:

$ bin/coffee -bce 'x for own x in l'
[stdin]:1:13: error: unexpected FORIN
x for own x in l
            ^^

(Not really proposing this, just iterating over options ;)

@vendethiel
Copy link
Collaborator

@nathanpalmer The solution is not to downgrade but to fix the code

@marchaefner This seems like a good solution, since it actually shrinks down the code. Something really needs to be done about the grammar, but that's another thing on its own.

@michaelficarra
Copy link
Collaborator

@marchaefner @Nami-Doc: Agreed. That's what CoffeeScriptRedux does.

@jashkenas
Copy link
Owner

@Nami-Doc -- want to send over your fix as a PR?

@vendethiel
Copy link
Collaborator

I'd feel ashamed knowing a code that bad is in the code of coffeescript. I started working on this because I thought new Literal('in') would work.
I'd rather ask @marchaefner, if you're fine with not parsing own-in

@vendethiel
Copy link
Collaborator

Oh yeah, while I'm meddling with grammar ...

# rule : 
'Assignable = TERMINATOR Expression'
# supposedly allowing that :
a =
5
# but also allows this
a = ; 5

but it doesn't seem to make sense to me

@michaelficarra
Copy link
Collaborator

Ha. Nice. Please open a new issue for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants