Skip to content

[SUGGESTION] Don't allow unused value inside function body #364

@realgdman

Description

@realgdman

I understand that it may be difficult to implement on cppfront side.

Consider the following, it's easy to write by mistake
foo: ()->int = 42;
bar: ()->int = { 13; } //value discarded; non-void function returns nothing

main: () -> int = {
std::cout << foo() << bar();
}

In that case of course cpp1 will give a warning about bar not returning value, but if it's not enforced that would be UB and crash.
But may be it is possible to track in cppfront if function has return value, return paths etc.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions