Skip to content

Value declaration compiles to unit #295

Description

@MeAmAnUsername

Summary
The value of a value declaration is supposed to be its expression, but it compiles to unit

Todo

  • Add tests
    • SingleBinder valdec
    • MultiBinder valdec
  • Fix bug

Reproduction
Given: func valDec() -> int = val x = 7, run Spoofax > Generate > Java
Expected: generates

@Override public Integer exec(ExecContext execContext, None input) throws Exception {
  final Integer x = new Integer (7);
  return x;
}

Actual: generates

@Override public Integer exec(ExecContext execContext, None input) throws Exception {
  final Integer x = new Integer (7);
  return None.instance;
}

Details
Value declarations used to have unit type and value. The intended semantics were changed to be the type and value of the expression that is assigned. Static analysis correctly gives no errors on the example function, but the compiler still generates UnitLit()

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions