musictheory / NilScript

Objective-C-style language superset of JavaScript with a tiny, simple runtime
Other
50 stars 5 forks source link

OJ and WebPack - issues with var's. #48

Closed IngwiePhoenix closed 9 years ago

IngwiePhoenix commented 9 years ago

Referencing: https://github.com/webpack/webpack/issues/1001#issuecomment-95735860

Could you look at the gist with the output and determine if the issue comes from OJ? As far as I am aware, the vars (var Foo and var Bar in my case) don't actually contain anything, do they?

iccir commented 9 years ago

This is correct behavior. See https://github.com/musictheory/oj#scope-and-class

Specifically, Foo may be a variable name used by a global library, hence, the oj compiler will not touch it. If Foo is an oj class in the current compilation unit, oj then knows that it is a class and will treat it as such.

You can also tell the compiler that Foo is a class by using @class Foo at the top of your file.

IngwiePhoenix commented 9 years ago

Very nice, thanks for that one. :) I am currently saving compiler state between complilations, so I get the correct behaviour. That, by the way, also fixed my problem. :)

Thanks for your help!