Skip to content

[BUG] Forward returning literals and rvalues not rejected. #381

Closed
@leejy12

Description

@leejy12

This Cpp2 code

global: i32 = 42;

forward_return_literal: () -> forward _ = {
    return 1;
}

forward_return_rvalue: () -> forward _ = {
    return global + 1;
}

compiles to

cpp2::i32 global {42}; 

[[nodiscard]] auto forward_return_literal() -> auto&&{
    return 1; 
}

[[nodiscard]] auto forward_return_rvalue() -> auto&&{
    return global + 1; 
}

which is problematic Cpp1. We should err when forward returning literals and rvalues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions