Skip to content

Fixed assignment bug in local scope #902

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kochelmonster
Copy link

Fixed the following bugs and avoids to emit the wrong "var" keyword.

def count_100(index):
for j in range(100):
index = index + 1
return index

Generated wrong to:

export var count_100 = function (index) {
for (var j = 0; j < 100; j++) {
var index = index + 1; // var is wrong
}
return index;
};


def count_101(index):
idx = index
for j in range(101):
idx = idx + 1
return idx

Generated wrong to:

export var count_101 = function (index) {
var idx = index;
for (var j = 0; j < 101; j++) {
var idx = idx + 1; // var is wrong
}
return idx;
};

def count_100(index):
    for j in range(100):
        index = index + 1
    return index

Generated wrong to:

export var count_100 = function (index) {
	for (var j = 0; j < 100; j++) {
		var index = index + 1;  // var is wrong
	}
	return index;
};

------

def count_101(index):
    idx = index
    for j in range(101):
        idx = idx + 1
    return idx

Generated wrong to:

export var count_101 = function (index) {
	var idx = index;
	for (var j = 0; j < 101; j++) {
		var idx = idx + 1;   // var is wrong
	}
	return idx;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant