Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value declaration compiles to unit #295

Open
4 tasks
MeAmAnUsername opened this issue May 13, 2022 · 0 comments
Open
4 tasks

Value declaration compiles to unit #295

MeAmAnUsername opened this issue May 13, 2022 · 0 comments
Labels
Component: code generation Something that concerns the generated code Priority: low Status: specified Enhancement that is ready to implement Type: bug Something isn't working

Comments

@MeAmAnUsername
Copy link
Owner

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()

@MeAmAnUsername MeAmAnUsername added Type: bug Something isn't working Status: specified Enhancement that is ready to implement Component: code generation Something that concerns the generated code Priority: low labels May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: code generation Something that concerns the generated code Priority: low Status: specified Enhancement that is ready to implement Type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant