Skip to content

No error for implicitly defined return value #1869

Closed
@shreydesai

Description

@shreydesai

Correct me if this issue has already been addressed, but I found the no error for an implicitly defined return value troubling. It seems as if this would not be static typing because the return value should explicitly defined (whatever it is) for statically typed languages.

I think there should be a difference between these two functions when run through the parser, in that the second one should raise an error for not having an explicitly defined return value:

def f() -> None:
    print('Hello world')

def g():
    print('Hello world')

In statically typed languages like Java, return values must be explicitly defined, whether they are void, Strings, or primitive data types, for instance:

public void test1() {
  System.out.println("Hello world");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions