Skip to content

Allow not specifying unit return type and value

Gustav Sörnäs requested to merge allow-no-entity-return into master

This is a bit of a hack solution. The ideal way would be handling zero sized types everywhere, which would mean solving #262 too. Instead, we only add support for

  1. Omitting the return type specifier on units
  2. Omitting the return value in blocks

Due to the hackiness, -> () is equivalent to omitting the return type specifier, but the ()-value is still not creatable. Maybe we should disallow -> () with a compiler error.


This now also supports instantiating units without a return type. We still talk about () as a type and value, but it can't be written directly.

Author checklist

  • New Diagnostics have at least one snapshot test that triggers it
  • New snapshot tests
    • Omitting return type but there is a final expression
    • Specifying the return type and omitting the final expression
    • The above, but for inner blocks instead of units
  • Other tests
    • Compiling units without return type doesn't codegen an output
    • Can instantiate units without return type (and passing them a port so it actually does something)
  • Added a line to CHANGELOG.md
Edited by Gustav Sörnäs

Merge request reports