Skip to content

Is global.get allowed in element segments? #2201

Closed

Description

@TethysSvensson

As far as I can tell from the webassembly spec, it should be valid to use the global.get instruction in an element segment.

However I am unable to use wat2wasm on this module

(module
  (import "m" "f" (global funcref))
  (table 0 10 funcref)
  (elem 0 (offset (i32.const 0)) funcref (global.get 0)))

If I try, I get this error:

foo.wat:4:43: error: invalid elem expression expression; must be either ref.null or ref.func.
  (elem 0 (offset (i32.const 0)) funcref (global.get 0)))
                                          ^^^^^^^^^^

If I use the --no-check flag I am able to override the check and generate a resulting .wasm file.

Looking at the generated file in a hexdump, it looks exactly like I would expect it to. However I am unable to get wasm2wat to accept this generated module, even if I use the --no-check flag.

Am I misreading the spec, or is this a bug in wabt?

Activity

  1. changed the title [-]Is `global.get` in element segment?[/-] [+]Is `global.get` allowed in element segments?[/+] on Apr 16, 2023
  2. sbc100 commented on Apr 16, 2023

    @sbc100
    Member

    Interesting, that does look like a bug in the support for the reference types proposal, but it also must represent a hole in the spec tests since wabt runs all the spec tests tests for reference types.

  3. sbc100 commented on Apr 17, 2023

    @sbc100
    Member

    I added a spec test to cover this case, but it will take a bit of work on the wabt side to fix it I think.

  4. added 5 commits that reference this issue on Aug 30, 2023
    aff63e4
    3fca756
    7d0fd5e
    d56e9e7
    a947ebc
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