JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
85 stars 3 forks source link

Context builder ignores fields in python class after typed assignment without expressions #319

Closed JSAbrahams closed 1 year ago

JSAbrahams commented 2 years ago

Description of Bug

Context builder misses class arguments if first one is a declaration without an accompanying expression

How to Reproduce

class MyClass:
    a: int
    b: int = 10
    def __init__(self): pass

Gives a class without field b, only field a is present. The constructor is also ignored.

Conversely, if we do:

class MyClass:
    def __init__(self): pass
    b: int = 10
    a: int

Then we have both a and b.

Expected behavior

In the first situation, we should also have both field a and b and the constructor should be checked.

Additional context

This does appear to be a bug with the underling python-parser-0.1.0. If a class starts with an Assignment, then no further statements are given and/or parsed.

JSAbrahams commented 1 year ago

Hm actually this is invalid Python code.