bytecodealliance/wac

`wac-parser` not checking for type declaration conflicting with previous export

Closed this issue · 2 comments

The following wac:

package test:comp;

let foo = new foo:bar {};

export foo as i;

interface i {
}

causes a panic in wac-parser:

thread 'main' panicked at crates/wac-parser/src/resolution/ast.rs:355:9:
assertion failed: prev.is_none()

This is because wac-parser is not emitting an error for the type declaration conflicting with the previous export.

I have a fix for this in the overhaul of wac-parser I'm doing to migration to wac-graph.

The new error:

error: failed to resolve document

  × type declaration `i` conflicts with a previous export of the same name
   ╭─[foo.wac:7:11]
 4 │ 
 5 │ export foo as i;
   ·               ┬
   ·               ╰── previous export is here
 6 │ 
 7 │ interface i {
   ·           ┬
   ·           ╰── conflicting type declaration `i`
 8 │ }
   ╰────