temperlang / temper

3 stars 0 forks source link

Class declaration in REPL does not export symbol #73

Open ben-509 opened 9 months ago

ben-509 commented 9 months ago

This is a minimal test case of an issue found in #70 and possibly the same underlying issue as #34:

$ class Bob {}
interactive#0: Bob__0
$ let foo(a: Bob): Int { 33 }
interactive#1: void

The interpreter handles this just fine, foo(new Bob()) works.

The translation fails in python, js, java with similar errors, only Python is shown here:

$ translate(1, "py")
1: let foo(a: Bob): Int { 33 }
              ┗━┛
[interactive#1:1+11-14]: interactive#0 does not export symbol Bob__0
Translated py for interactive#1
  interactive-0001/
    interactive_0001/
      __init__.py: text/python
        from interactive_0001.chunk import *
      chunk.py: text/python
        from typing import Any as Any0
        from builtins import int as int1
        Bob__1: 'Any0' = ('<<lang.temper.value.TType: Type, lang.temper.value.Value: Bob__0: Type>>', NotImplemented)[1]
        def foo(a__2: 'Any0') -> 'int1':
          return 33
      __init__.py.map: application/json
        { "version": 3, "file": "py/interactive-⋯rces": [], "names": [], "mappings": "A" }
      chunk.py.map: application/json
        { "version": 3, "file": "py/interactive-⋯CC,IAAC,CAAE,OAAgB,IAAA,AAAV,OAAG;AAAG" }

$ translate(0, "py")
Translated py for interactive#0
  interactive-0000/
    interactive_0000/
      __init__.py: text/python
        from interactive_0000.chunk import *
      chunk.py: text/python
        from typing import Any as Any0
        class Bob__0:
          __slots__ = ()
          def constructor__3(this__1) -> 'None':
            None
          def __init__(this__1) -> None:
            this__1.constructor__3()
        return__4: 'Any0' = ('<<lang.temper.value.TType: Type, lang.temper.value.Value: Bob__0: Type>>', NotImplemented)[1]
        export = return__4
      __init__.py.map: application/json
        { "version": 3, "file": "py/interactive-⋯rces": [], "names": [], "mappings": "A" }
      chunk.py.map: application/json
        { "version": 3, "file": "py/interactive-⋯AH,eAAG,EAAA,AAAH,CAAG,CAAA;AAAG,SAAAA" }