Skip to content

Invalid WAT file format #2854

Open
Open
@Mudloop

Description

@Mudloop

Bug description

I'm not sure if this is a bug with AssemblyScript, Binaryen or wat2wasm, but the generated .wat files can contain things like this :

(func $"~lib/map/Map<u32,~lib/string/String>#set:buckets" (param $this i32) (param $buckets i32)
  ..
)

When using wat2wasm, it will complain about "unexpected token ..., expected a numeric index or a name (e.g. 12 or $foo)."

This could be solved by removing the quotes, and using a minus sign instead of the commas. That should still prevent name clashes (since I don't believe a minus sign is a valid character in function or variable names), and that way wat2wam doesn't complain about it.

So in this case, that would make it :

(func $~lib/map/Map<u32-~lib/string/String>#set:buckets (param $this i32) (param $buckets i32)

It's possible that the $"" format is perfectly valid and wat2wasm just doesn't know how to deal with it, but still, probably a good idea to be compatible with commonly used tools?

Steps to reproduce

Build any project which references a generic type with more than 1 generic type parameter, ie Map<u32, string>

AssemblyScript version

0.27.27

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions