diff --git a/testdata/issues/issue347.wit b/testdata/issues/issue347.wit new file mode 100644 index 00000000..00f720b5 --- /dev/null +++ b/testdata/issues/issue347.wit @@ -0,0 +1,16 @@ +/// This comment must exist to trigger failure. +package issues:issue347; + +world foo-command { + import issues:inner/custom; +} + +package issues:inner { + interface custom { + words: func(text: string) -> list; + } + + world the-world { + export custom; + } +} diff --git a/testdata/issues/issue347.wit.json b/testdata/issues/issue347.wit.json new file mode 100644 index 00000000..7a0014e5 --- /dev/null +++ b/testdata/issues/issue347.wit.json @@ -0,0 +1,78 @@ +{ + "worlds": [ + { + "name": "the-world", + "imports": {}, + "exports": { + "interface-0": { + "interface": { + "id": 0 + } + } + }, + "package": 0 + }, + { + "name": "foo-command", + "imports": { + "interface-0": { + "interface": { + "id": 0 + } + } + }, + "exports": {}, + "package": 1 + } + ], + "interfaces": [ + { + "name": "custom", + "types": {}, + "functions": { + "words": { + "name": "words", + "kind": "freestanding", + "params": [ + { + "name": "text", + "type": "string" + } + ], + "result": 0 + } + }, + "package": 0 + } + ], + "types": [ + { + "name": null, + "kind": { + "list": "string" + }, + "owner": null + } + ], + "packages": [ + { + "name": "issues:inner", + "interfaces": { + "custom": 0 + }, + "worlds": { + "the-world": 0 + } + }, + { + "name": "issues:issue347", + "docs": { + "contents": "This comment must exist to trigger failure." + }, + "interfaces": {}, + "worlds": { + "foo-command": 1 + } + } + ] +} \ No newline at end of file diff --git a/testdata/issues/issue347.wit.json.golden.wit b/testdata/issues/issue347.wit.json.golden.wit new file mode 100644 index 00000000..7185f7d1 --- /dev/null +++ b/testdata/issues/issue347.wit.json.golden.wit @@ -0,0 +1,16 @@ +/// This comment must exist to trigger failure. +package issues:issue347; + +world foo-command { + import issues:inner/custom; +} + +package issues:inner { + interface custom { + words: func(text: string) -> list; + } + + world the-world { + export custom; + } +} diff --git a/wit/wit.go b/wit/wit.go index c1f8b70f..8a425f2d 100644 --- a/wit/wit.go +++ b/wit/wit.go @@ -1206,9 +1206,9 @@ func (p *Package) WIT(ctx Node, name string) string { b.WriteString("}\n") } // Return empty string if package has no contents - // if i == 0 { - // return "" - // } + if filter != nil && i == 0 { + return "" + } return b.String() }