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

Python target generates code that raises NameError #138

Closed
dahlia opened this issue May 24, 2017 · 1 comment
Closed

Python target generates code that raises NameError #138

dahlia opened this issue May 24, 2017 · 1 comment
Assignees
Labels
cmp:compiler Component: Compiler backend (e.g., annotation processors, code generators) target:python typ:bug Type: Bug/defect

Comments

@dahlia
Copy link
Member

dahlia commented May 24, 2017

Python target generates code that raises NameError when a referring type is above than a referred type e.g.:

record a (b value);
record b (text value);

The above code generates a Python code like the following (though it's approximated, it shows a point):

class A:
    __nirum_field_types__ = {'value': B}  # B is not defined at the moment.

class B:
    __nirum_field_types__ = {'value': str}
@dahlia dahlia added typ:bug Type: Bug/defect target labels May 24, 2017
@dahlia
Copy link
Member Author

dahlia commented Jun 21, 2017

We need to encode all forward references as string literals and get types always through typing.get_type_hints() function.

dahlia added a commit to dahlia/nirum-python that referenced this issue Jun 22, 2017
@dahlia dahlia closed this as completed in 679c0a8 Jun 23, 2017
@dahlia dahlia added cmp:compiler Component: Compiler backend (e.g., annotation processors, code generators) target:python and removed target labels Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmp:compiler Component: Compiler backend (e.g., annotation processors, code generators) target:python typ:bug Type: Bug/defect
Projects
None yet
Development

No branches or pull requests

2 participants