Skip to content
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

problem with invert operator expression #887

Open
jggatc opened this issue Dec 23, 2024 · 0 comments
Open

problem with invert operator expression #887

jggatc opened this issue Dec 23, 2024 · 0 comments
Labels

Comments

@jggatc
Copy link

jggatc commented Dec 23, 2024

Expression with invert operator of an class instance causes error.

Error occurs with iobj = ~(obj) expression.
Browser error: Uncaught TypeError: Function.prototype.toString called on incompatible object.
Worked properly with iobj = obj.__invert__() expression.

python code:

class Obj:
    def __init__(self, x):
        self.x = x
    def __invert__(self):
        return ~self.x

# __pragma__ ('opov')
def op_invert():
    obj = Obj(42)
    if False:
        iobj = ~(obj)
# __pragma__ ('noopov')

op_invert()

compiled javascript code with ~(obj):

export var op_invert = function () {
	var obj = __call__ (Obj, null, 10);
	var iobj = ~(obj);
};

compiled javascript code with obj.__invert__():

export var op_invert = function () {
	var obj = __call__ (Obj, null, 10);
	var iobj = (function () {
		var __accu0__ = obj;
		return __call__ (__accu0__.__invert__, __accu0__);
	}) ();
};

env: Python3.9 venv with pip install Transcrypt
testing: Firefox version 133 in Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants