I've been playing with the compiler over the last few days trying to address this bug. Replacing the __init__ part with the constructor was easy, the problem is that kwargs doesn't work as expected on class methods. Upon further investigation I realized that this is because of the way it triggers the function call from within the decorator, effectively discarding the object that the function should be applied to.
Basically, the culprit is this guy in kwargs function definition: f.apply(f, args). There were some other minor bugs with kwargs, which I've fixed as well. I've also improved the tests for kwargs to test class methods. There is only one bug remaining, which I can't seem to figure out and the workaround is relatively easy, so I gave up on it for now. Basically, the following call seems to lose its arguments:
test = KeywordArgsTest(a=1, b=2)
Yet adding a fake positional argument (which will get overridden by a/b) fixes the issue. This also only seems to be the case with the constructor, and not other methods, and only when function is called via 'new' operator in JS. However, I'm not seeing this issue outside of the test, with the following example I tried:
function c() {
console.log(arguments);
}
c({a: 1}); // works fine
new c({a: 1}) // works fine, yet this same logic loses its arguments in the test - the breakage occurs prior to kwargs call, my constructor is now separated from the class-defining function, so it doesn't look like kwargs is at fault here
If someone can figure out what's going on with the test, I'd love to hear it. Otherwise, the logic is usable as is if you don't mind the 'fake' arg when using it in the constructor.