Skip to content

[spectec] Wasm 1.0: CVTOP typing accepts illegal conversion/operator combinations #2302

Open

Description

@lzy0505

The Wasm 1.0 SpecTec conversion typing rules accept arbitrary combinations of source type, destination type, and conversion operator.

In specification/wasm-1.0/6-typing.spectec:

;; TODO: move side conditions to syntax
rule Instr_ok/cvtop-reinterpret:
  C |- CVTOP nt_1 nt_2 REINTERPRET : nt_2 -> nt_1
  -- if $size(nt_1) = $size(nt_2)

rule Instr_ok/cvtop-convert:
  C |- CVTOP nt_1 nt_2 cvtop : nt_2 -> nt_1

The second rule admits every cvtop, including REINTERPRET, so it also bypasses the first rule’s check.

The syntax rule only requires distinct source and destination types:

| CVTOP valtype_1 valtype_2 cvtop
    hint(show %1.%3#_#%2)
  -- if valtype_1 =/= valtype_2

The PDF (2.4.1) restricts those combinations through syntax:

nn, mm ::= 32 | 64
sx     ::= u | s

instr ::= ...
        | i32.wrap_i64
        | i64.extend_i32_sx
        | inn.trunc_fmm_sx
        | f32.demote_f64
        | f64.promote_f32
        | fnn.convert_imm_sx
        | inn.reinterpret_fnn
        | fnn.reinterpret_inn

Activity

  1. rossberg commented on Oct 23, 2026

    @rossberg
    Member

    Indeed, the precise spec was never backported to the 1.0 SpecTec version, because nobody has used that much anymore. The respective constraints from the 3.0 spec have at least been backported to 2.0 in this branch, but that's still awaiting upstreaming, probably until after the PLDI deadline. @DCupello1

    For 1.0, the same should work. Please don't hesitate to open a PR.

  2. BLVCK-MAMBA-6 commented on Nov 26, 2026

    @BLVCK-MAMBA-6

    Hi @rossberg, it's been a little over a month, so has anyone picked this up yet? If not, I'll take it and open a PR. I'll use the 2.0 backport you mentioned as the reference for the 1.0 conversion constraints. Thanks!

  3. rossberg commented on Nov 27, 2026

    @rossberg
    Member

    Sorry for the delay, everybody was busy with deadlines. @DCupello1 is now looking into upstreaming the relevant changes to the 2.0 spec. I don't think that includes changes to the 1.0 spec, so you're welcome to open a PR.

  4. DCupello1 commented on Nov 27, 2026

    @DCupello1
    Contributor

    Sorry for the delay, everybody was busy with deadlines. @DCupello1 is now looking into upstreaming the relevant changes to the 2.0 spec. I don't think that includes changes to the 1.0 spec, so you're welcome to open a PR.

    I made it so that it does also include the changes to the 1.0 spec.

  5. BLVCK-MAMBA-6 commented on Nov 27, 2026

    @BLVCK-MAMBA-6

    Thanks for the update, @DCupello1. Does #2357 now cover the Wasm 1.0 CVTOP constraints described in this issue as well? If so, I’ll avoid opening a duplicate fix. If any part is still outstanding, including regression tests, I’d be happy to pick that up.

  6. DCupello1 commented on Nov 27, 2026

    @DCupello1
    Contributor

    Thanks for the update, @DCupello1. Does #2357 now cover the Wasm 1.0 CVTOP constraints described in this issue as well? If so, I’ll avoid opening a duplicate fix. If any part is still outstanding, including regression tests, I’d be happy to pick that up.

    Yes, #2357 does cover the Wasm 1.0 CVTOP constraints. There are still tests that likely need to be modified to match the new changes, so if you feel like doing that, you are welcome to do so.

  7. BLVCK-MAMBA-6 commented on Nov 27, 2026

    @BLVCK-MAMBA-6

    Thanks, @DCupello1! I'll take a look at the updated Wasm 1.0 rules in #2357 and work on aligning the existing tests with the new constraints, including regression coverage for invalid CVTOP combinations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions