aduros / flambe

Rapidly cook up games for HTML5, Flash, Android, and iOS.
https://github.com/aduros/flambe/wiki
MIT License
745 stars 118 forks source link

Uncaught SyntaxError: Duplicate data property in object literal not allowed in strict mode #264

Open quinnhoener opened 10 years ago

quinnhoener commented 10 years ago

When using the nightlies to run either "flambe build html --debug" or "flambe run html --debug" throws the above error and the page doesn't load. Looking at the line it's telling me in Chrome's Console.log is this the properties line:

flambe_platform_DummyPlayback.prototype = { set_paused: function(paused) { return true; } ,get_complete: function() { return this._complete; } ,dispose: function() { } ,class: flambe_platform_DummyPlayback ,properties: {get_complete:"get_complete",set_paused:"set_paused",get_complete:"get_complete",set_paused:"set_paused"} };

quinnhoener commented 10 years ago

Running without "--debug" seems to build and run fine.

volkipp commented 10 years ago

I've also run into the issue of having duplicate setters or getters. The only way I was able to fix it was to revert back to an official release, re-download the nightly build, and change back to the developer build in haxelib. Occasionally this still pops up for me. It seems to coincide with the new compilation server stuff.

aduros commented 10 years ago

That's odd... it almost seems like a Haxe bug. What version of Haxe are you running?

Could you post a simple project that reproduces it? It doesn't seem to break for me even when I use Reflect.getProperty.

volkipp commented 10 years ago

I'm on Haxe 3.1.3

volkipp commented 10 years ago

Alright, I've been trying to figure out what specifically causes this error but I'm not able to boil it down into a small use case. It seems to be happening intermittently. I was able to narrow it down to two lines of code. In this scenario:

var pb :Playback = _assets.get('lair').getSound("typetext").loop(1);
pb.paused = true;

causes the uncaught syntax error to be thrown. If I comment out the pb.paused = true line, everything works fine. Very strange.

If I rework my code slightly to look like this, the compiler error also goes away:

var pack :AssetPack = _assets.get('lair');
var pb :Playback = pack.getSound("typetext").loop(1);
pb.paused = true;

The weird thing is that when I put just this code into a barebones use case with just this code and these classes, I cannot get the error to come up again.

Even stranger, when I go back to the original 'big' project and recompile with the first use case which caused the error... The error no longer comes up.

So, I think you're right that it has something to do with the Haxe compiler. I also think it has something to do with the compilation server and cache somehow. It also seems to have something to do with multiple function calls with the word 'get' in them (for instance in getters and setters).

volkipp commented 10 years ago

I guess another thing I just noticed is that in my project where this came up, it also stalled on a playback just like in Quinn's project. I wish I would have looked at the javascript error to see if it was in the same place or not. :(

volkipp commented 10 years ago

Just had this pop up in another project, it looks like it's not just happening in DummyPlayback. I saw this come up on BasicMouse: ,__class__: flambe_platform_BasicMouse,__properties__: {get_y:"get_y",get_x:"get_x",set_cursor:"set_cursor",get_y:"get_y",get_x:"get_x",get_supported:"get_supported"}

aduros commented 10 years ago

Thanks guys, filed at HaxeFoundation/haxe#3156 since it seems to be a compiler issue.

Simn commented 10 years ago

Does anyone have a small project which reproduces this behavior?