Skip to content

Dict increment assignment ( dict[key] += 1 ) not working in Transcrypt/Screeps Python #49

Description

@moreMizzh

Describe the bug

In the Screeps Python (Transcrypt) environment, increment assignment on a dictionary value does not work as expected.

To Reproduce

Example code:

cs_dict = {"a": 0}
console.log("a: ", cs_dict["a"])
cs_dict["a"] += 1
console.log("a: ", cs_dict["a"])
cs_dict["a"] = 1
console.log("a: ", cs_dict["a"])

Actual behavior

The output is:

a:  0
a:  0
a:  0

Expected behavior

The expected output should be:

a:  0
a:  1
a:  1

Additional context

This issue makes it impossible to use dict[key] += 1 for counting in Screeps Python.
Please help to check if this is a Transcrypt compatibility bug or a Screeps Python integration issue.

Thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions