Skip to content

if/alt expressions don't understand how to return functions that fail #452

Closed
@brson

Description

@brson

In the following example the first arm of the if expression doesn't translate:

fn f() -> ! { fail }

fn g() -> int {
  auto x = if (true) {
    f()
  } else {
    10
  };
  ret x;
}

Trans thinks that f() returns int (because x is int) and tries to copy the result of f, which is not int. Replacing f() with a plain fail expression works as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions