Skip to content

Commit 0020099

Browse files
authored
Merge pull request #355 from bytecodealliance/ydnar/issue347
wit: do not emit WIT for empty packages
2 parents 999af0b + 32a5643 commit 0020099

4 files changed

Lines changed: 113 additions & 3 deletions

File tree

testdata/issues/issue347.wit

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// This comment must exist to trigger failure.
2+
package issues:issue347;
3+
4+
world foo-command {
5+
import issues:inner/custom;
6+
}
7+
8+
package issues:inner {
9+
interface custom {
10+
words: func(text: string) -> list<string>;
11+
}
12+
13+
world the-world {
14+
export custom;
15+
}
16+
}

testdata/issues/issue347.wit.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"worlds": [
3+
{
4+
"name": "the-world",
5+
"imports": {},
6+
"exports": {
7+
"interface-0": {
8+
"interface": {
9+
"id": 0
10+
}
11+
}
12+
},
13+
"package": 0
14+
},
15+
{
16+
"name": "foo-command",
17+
"imports": {
18+
"interface-0": {
19+
"interface": {
20+
"id": 0
21+
}
22+
}
23+
},
24+
"exports": {},
25+
"package": 1
26+
}
27+
],
28+
"interfaces": [
29+
{
30+
"name": "custom",
31+
"types": {},
32+
"functions": {
33+
"words": {
34+
"name": "words",
35+
"kind": "freestanding",
36+
"params": [
37+
{
38+
"name": "text",
39+
"type": "string"
40+
}
41+
],
42+
"result": 0
43+
}
44+
},
45+
"package": 0
46+
}
47+
],
48+
"types": [
49+
{
50+
"name": null,
51+
"kind": {
52+
"list": "string"
53+
},
54+
"owner": null
55+
}
56+
],
57+
"packages": [
58+
{
59+
"name": "issues:inner",
60+
"interfaces": {
61+
"custom": 0
62+
},
63+
"worlds": {
64+
"the-world": 0
65+
}
66+
},
67+
{
68+
"name": "issues:issue347",
69+
"docs": {
70+
"contents": "This comment must exist to trigger failure."
71+
},
72+
"interfaces": {},
73+
"worlds": {
74+
"foo-command": 1
75+
}
76+
}
77+
]
78+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// This comment must exist to trigger failure.
2+
package issues:issue347;
3+
4+
world foo-command {
5+
import issues:inner/custom;
6+
}
7+
8+
package issues:inner {
9+
interface custom {
10+
words: func(text: string) -> list<string>;
11+
}
12+
13+
world the-world {
14+
export custom;
15+
}
16+
}

wit/wit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,9 +1206,9 @@ func (p *Package) WIT(ctx Node, name string) string {
12061206
b.WriteString("}\n")
12071207
}
12081208
// Return empty string if package has no contents
1209-
// if i == 0 {
1210-
// return ""
1211-
// }
1209+
if filter != nil && i == 0 {
1210+
return ""
1211+
}
12121212
return b.String()
12131213
}
12141214

0 commit comments

Comments
 (0)