Commits

rkruppe  committed c1deafe

Handle collisions of typeident() with builtins differently

  • Participants
  • Parent commits 7e9da72
  • Branches experiments

Comments (0)

Files changed (3)

File 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)

File 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)
 

File 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')