Skip to content

Bug in interp_Lwhile.py: missing return in interpreter definition.#40

Open
elavoie wants to merge 1 commit intoIUCompilerCourse:mainfrom
elavoie:patch-1
Open

Bug in interp_Lwhile.py: missing return in interpreter definition.#40
elavoie wants to merge 1 commit intoIUCompilerCourse:mainfrom
elavoie:patch-1

Conversation

@elavoie
Copy link

@elavoie elavoie commented Nov 6, 2025

Missing 'return' for the body case.

Without this 'return' the following code prints 'None' instead of '9':

def func(a: int) -> int:
    i = True

    while i:
       a = a - 1
       i = False

    # print(a) at this point will print 9
    return a

print(func(10)) # expected 9, got None

Missing 'return' for the body case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant