Skip to content

Order in which properties are added is not honored #84

@brunexgeek

Description

@brunexgeek

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions