-
Notifications
You must be signed in to change notification settings - Fork 2k
Javascript warning in Mozilla's engine #3579
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
Comments
Well, you're the one responsible for your code — you were the one who made it |
But what the correct thing to do?
generates the exact same JS code. |
I'd suggest doing it regardless of whether you're using coffeescript or not.
No, it does not. In first case it would return |
Could this warning be from the outer IIFE, which indeed does not return anything? |
No, probably not: it says it might not return something. The IIFE will never return anything, and it's easy to see. Also, I don't see them disallowing IIFEs. Also, damn these little phones that make it so easy to reopen! |
@Nami-Doc, i don't think this issue is about the enclosing IIFE. If i understand correctly, it's about a function that's supposed to act as a procedure (i.e. only have side effects and not return anything) being compiled into something that indeed returns something. I'd say it's related to #899 and others. |
Do you think some kind of middle ground could be found here? :
|
No. This would break existing code and be inconsistent. Just put a |
In this case, omitting the early return and using only one at the end would probably make it clearer that the function returns nothing: (obj) ->
obj.value += 1 if obj.value >= 0
return |
When the mozilla JS engine has its strict option turned on, you get a lot of warning for CoffeeScript code transformed into JS code.
Most of them are related to return values :
It seems if you have the following CoffeeScript code :
you get something like this :
Now you can see the inconsistency between the 2 different return statement.
I'm wondering if this is something CoffeeScript people have given a thought to before, or if I should just give up on strict mode with JS code generated from CoffeeScript.
Thanks!
The text was updated successfully, but these errors were encountered: