← 输入框|github.com|刷新
Skip to content

Imports not working #2032

Closed
Closed

Description

@rebcabin

I attempted to refactor tests into their own file, main.py. This works in CPython but not in LPython

repro: https://github.com/rebcabin/lpython/tree/brian-lasr/lasr/LP-pycharm/Issue2032

offending code:

from lasr_stringio import StringIO, __post_init__
from lasr_lexer import stringio_test, regex_test, lexer_test


if __name__ == '__main__':
    integer_asr : str = '(Integer 4 [])'

    fd   : StringIO = StringIO(integer_asr)
    __post_init__(fd)  # Issue #1929

    stringio_test(fd, integer_asr)
    regex_test()
    lexer_test() # lexer)

run:

# CPYTHON

(lp) ┌─(~/CLionProjects/lpython/lasr/LP-pycharm/Issue2032)───────────────────────────────────────────────────────────────────────────────────────────────(brian@Golf37:s012)─┐
└─(17:22:20 on brian-lasr ✭)──> PYTHONPATH='../../../src/runtime/lpython' python main.py                                                                  ──(Sun,Jun25)─┘
STRINGIO TEST
READ-SEEK-TELL-TEST
REGEX TEST
LEXER TEST

# LPYTHON

(lp) ┌─(~/CLionProjects/lpython/lasr/LP-pycharm/Issue2032)───────────────────────────────────────────────────────────────────────────────────────────────(brian@Golf37:s012)─┐
└─(17:22:25 on brian-lasr ✭)──> ~/CLionProjects/lpython/src/bin/lpython -I. main.py                                                                       ──(Sun,Jun25)─┘
semantic error: Type mismatch in procedure call; the types must be compatible
  --> main.py:11:19
   |
11 |     stringio_test(fd, integer_asr)
   |                   ^^ type mismatch (passed argument type is StringIO but required type is StringIO)

  --> ./lasr_lexer.py:29:30
   |
29 | def stringio_test(fd : InOut[StringIO], integer_asr : str):
   |                              ^^^^^^^^ type mismatch (passed argument type is StringIO but required type is StringIO)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions