Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment functions with compound statement #832

Closed
MatthiasJ1 opened this issue Mar 4, 2024 · 1 comment
Closed

Assignment functions with compound statement #832

MatthiasJ1 opened this issue Mar 4, 2024 · 1 comment

Comments

@MatthiasJ1
Copy link

Assignment functions whose last statement is a compound statement should return the value of the final expression of the active code path.

def f(x)=
    if x:
        # some code
        x+1
    else: 0

def f(x)=
    match x:
        case 0: -1
        case _: x

def f(x)=
    with open(x, "r"):
        x.read()

Compiles to (3.10):

def f(x):
    if x:
        # some code
        return x+1
    else:
        return 0

def f(x):
    match x:
        case 0: return -1
        case _: return x

def f(x):
    with open(x, "r"):
        return x.read()
@evhub
Copy link
Owner

evhub commented Mar 5, 2024

Closing as duplicate of #190.

@evhub evhub closed this as completed Mar 5, 2024
@evhub evhub added feature and removed modification labels Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants