Commits

rkruppe committed c1deafe

Handle collisions of typeident() with builtins differently

Comments (0)

Files changed (3)

tutagx/meta/common.py

     that nevertheless leads to somewhat readable output.
     """
     def visit_float(node):
-        return 'float_num'
+        return 'float'
 
     def visit_integer(node):
-        return 'integer'
+        return 'int'
 
     def visit_string(node):
-        return 'string'
+        return 'str'
 
     def visit_list(node):
         return 'list_' + visit(node.items)

tutagx/util/codegen.py

+import builtins
 from types import GeneratorType
 from contextlib import contextmanager
 from collections import defaultdict, deque
         of :arg:`seen`.
         """
         self._generated = defaultdict(int)
-        self._taken = set(seen)
+        self._taken = set(dir(builtins)) | set(seen)
         if sig is not None:
             self._taken |= set(sig.params)
 

tutagx/util/tests/test_codegen.py

         assert symtab.new('foo') == 'foo'
         assert symtab.new('foo') == 'foo2'
 
+    def test_builtins_reserved(self, symtab):
+        assert symtab.new('int') == 'int1'
+
 
 def test_signature():
     sig = Signature('$obj', 'seen', 'x')