I've encountered something that either shows that I'm still missing some piece of understanding, or there's a bug. I've tried to boil it down to a simple case.
Here is a simple test library which is transpiled using "rapydscript --bare":
from __python__ import bound_methods
class A:
def __init__(self, x, y, **args):
self.x = x
self.y = y
self.args = []
for a in args:
GSprint(a, args[a])
self.args.append([a,args[a]])
def get(self):
ret = [self.x, self.y]
for a in self.args:
ret.append(a[0])
ret.append(a[1])
return ret
b = A(3, 7, canine='dog', feline='cat', states=50)
GSprint(b.get())
Here is a JavaScript program that uses the library:
var test = new A(50, 60, {canine:'coyote', feline:'jaguar', states:23})
console.log('Return:', test.get())
The output from execution shows that inside the library b = A(...) works properly, but test = new A(...) in the program that uses the library does not work properly:
3 7 Symbol(kwargs-object)
true Object {canine: "dog", feline: "cat", states: 50, Symbol(kwargs-object): true}
canine dog
feline cat
states 50
[3, 7, "canine", "dog", "feline", "cat", "states", 50]
50 60 Symbol(kwargs-object)
undefined Object {canine: "coyote", feline: "jaguar", states: 23}
Return: [50, 60]
The library contains this statement:
if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {};
If I remove the test for ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true
, like this,
if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object") ρσ_kwargs_obj = {};
both instances of the class work properly:
3 7 Symbol(kwargs-object)
true Object {canine: "dog", feline: "cat", states: 50, Symbol(kwargs-object): true}
canine dog
feline cat
states 50
[3, 7, "canine", "dog", "feline", "cat", "states", 50]
50 60 Symbol(kwargs-object)
undefined Object {canine: "coyote", feline: "jaguar", states: 23}
canine coyote
feline jaguar
states 23
Return: [50, 60, "canine", "coyote", "feline", "jaguar", "states", 23]
In my actual application things work only if I make the change in the test, and the deletion doesn't seem to have any bad consequences. What is the function of that test?