Files
wit-bindgen/tests/codegen/result-empty.wit
Dan Gohman 1a3acf9257 Correct the accounting for results containing empty types. (#610)
* Correct the accounting for results containing empty types.

Empty types are special-cased in the C backend because C doesn't allow
zero-sized types. In the case of a result containing an empty type,
when processing the ok side, increment the return value counter even
if the store is omitted due to the value being empty.

Fixes #609.

* Test all the combinations of non-empty, empty, and absent.
2023-07-12 13:21:53 -07:00

30 lines
605 B
Plaintext

package local:demo
interface my-interface {
variant stuff {
this,
that
}
record empty {
}
stuff-or-stuff: func() -> result<stuff, stuff>
stuff-or-empty: func() -> result<stuff, empty>
empty-or-stuff: func() -> result<empty, stuff>
empty-or-empty: func() -> result<empty, empty>
stuff-or-absent: func() -> result<stuff>
absent-or-stuff: func() -> result<_, stuff>
empty-or-absent: func() -> result<empty>
absent-or-empty: func() -> result<_, empty>
absent-or-absent: func() -> result
}
world my-world {
import my-interface
}