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

Order in which properties are added is not honored #84

Open
brunexgeek opened this issue Oct 17, 2021 · 0 comments
Open

Order in which properties are added is not honored #84

brunexgeek opened this issue Oct 17, 2021 · 0 comments

Comments

@brunexgeek
Copy link

brunexgeek commented Oct 17, 2021

Using the README.md example as starting point:

var obj = { key: "hello" };
obj["newKey"] = "test";
console.log(obj);

If we add the newKey property after the console.log, it should not appear in the output.

var obj = { key: "hello" };
console.log(obj);
obj["newKey"] = "test";

However, ts2c include all properties in the C definition (not the actual problem) and take them all into account when the object is used. This change the program semantic.

The C program output for this case is

{ key: "hello", newKey: "(null)" }

but should be

{ key: "hello" }

since newKey do not exists when console.log is called. Just for comparison, this would not happen if the internal representation for objects were actually a dictionary (possibly with some performance penalties).

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

No branches or pull requests

1 participant