binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

`isConstantExpression` should be combined with `isValidInConstantExpression`

Open tlively opened this issue 3 years ago • 3 comments

These seem like they should do the same thing, but their behavior is very different. Probably that's a bug?

tlively avatar Jul 29 '22 02:07 tlively

Alternatively, if the behavior is intended to be different, the function names should make that clear.

tlively avatar Jul 29 '22 02:07 tlively

The former is "constant in the compiler sense", i.e., can be constant propagated. The latter is "constant-expression in the wasm spec sense", which means it can fit in a global's init etc. I agree we should rename one of them. Is there a more precise spec name for the latter perhaps? If not, maybe just adding "spec" in the name could help.

kripken avatar Jul 29 '22 17:07 kripken

No, unfortunately the spec just describes them as "constant." We also informally use "constant initializer," though, so that might work.

tlively avatar Jul 29 '22 18:07 tlively