Skip to content

Different behaviour of overload with return and without return #399

Closed
@Smit-create

Description

@Smit-create

On this python code, overload works fine and prints 3 as the result:

@overload
def add(a: i32) -> i32:
    return a

@overload
def add(a: i32, b: i32) -> i32:
    return a+b

print(add(1, 2))

But the following one fails:

@overload
def add(a: i32):
    print(a)

@overload
def add(a: i32, b: i32):
    print(a+b)

add(1, 2)

ASR:

    throw LFortranException("ASR verify failed: " + error_msg);
LFortranException: ASR verify failed: 92:100: SubroutineCall::m_name cannot point outside of its symbol table

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