nirum-lang / nirum

Nirum: IDL compiler and RPC/distributed object framework for microservices
https://nirum.org/
GNU General Public License v3.0
121 stars 27 forks source link

Python target generates code that raises NameError #138

Closed dahlia closed 7 years ago

dahlia commented 7 years ago

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 commented 7 years ago

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