Skip to content
This repository has been archived by the owner. It is now read-only.

Fixed Unknown constant type <class 'frozenset'> in function definition #849

Merged

Conversation

@BPYap
Copy link
Contributor

@BPYap BPYap commented Jun 26, 2018

Previously when a set/frozenset appears as a constant in function definition, voc will fail during transpilation, for example, the code below will raise AssertionError: Unknown constant type <class 'frozenset'> during transpilation:

def func():
    1 in {1, 2, 3, 4, 5, 6}

This PR solve this issue by converting frozenset constant to a tuple when blocks.add_tuple is executing.

elif isinstance(value, bytes):
elif isinstance(value, frozenset):
self.add_opcodes(
python.Set(),
Copy link
Member

@freakboy3742 freakboy3742 Jul 6, 2018

Shouldn't this be FrozenSet?

@@ -181,6 +181,58 @@ def add_tuple(self, data):
java.Init('java/util/ArrayList'),
)

def add_value(val):
Copy link
Member

@freakboy3742 freakboy3742 Jul 6, 2018

It's better to avoid inner methods if you can.

Copy link
Member

@freakboy3742 freakboy3742 left a comment

👍

@freakboy3742 freakboy3742 merged commit df96c08 into beeware:master Jul 13, 2018
5 checks passed
@BPYap BPYap deleted the fix-frozenset-in-function-definition branch Jul 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants