Skip to content

Non-`extern` units following each other causes context overwrite

Code to reproduce

#[no_mangle(all)]
extern entity fNToRecFN <#uint intWidth, #uint expWidth, #uint sigWidth>(
    control: uint<1>,
    signedIn: bool,
    in: uint<intWidth>,
    roundingMode: uint<3>,
    out: inv &uint<{expWidth + sigWidth + 1}>,
    exceptionFlags: inv &uint<5>
);

/// Converts back from a recoded format to standard format.

entity recFNToFN <#uint expWidth, #uint sigWidth>(
     in: uint<{expWidth + sigWidth + 1}>,
     out: inv &uint<{expWidth + sigWidth}>
);

(...or a link to a repository)

Reported error

error: This entity is missing a body
   ┌─ src/hardfloat_sys.spade:26:1

26 │ ╭ entity recFNToFN <#uint expWidth, #uint sigWidth>(
27 │ │      in: uint<{expWidth + sigWidth + 1}>,
28 │ │      out: inv &uint<{expWidth + sigWidth}>
29 │ │ );
   │ ╰─^

   = Did you forget to add the entity's body?

29 │ ) {}
   │  ~~~
   = Or did you mean to declare an `extern` entity?

26 │ extern entity recFNToFN <#uint expWidth, #uint sigWidth>(
   │ +++++++

bug: overwriting previously uncleared item context
   ┌─ src/hardfloat_sys.spade:34:1

26 │ entity recFNToFN <#uint expWidth, #uint sigWidth>(
   │ ------ previous context set here
   ·
34 │ entity iNToRecFN<#uint intWidth, #uint expWidth, #uint sigWidth>(
   │ ^^^^^^ new context set because of this

   = note: This is an internal bug in the compiler.
           We would appreciate if you opened an issue in the repository:
           https://gitlab.com/spade-lang/spade/-/issues/new?issuable_template=Internal%20bug