Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions design/mvp/Explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2515,12 +2515,13 @@ plainname ::= <label>
| '[constructor]' <label>
| '[method]' <label> '.' <label>
| '[static]' <label> '.' <label>
label ::= <fragment>
| <label> '-' <fragment>
label ::= <first-fragment> ( '-' <fragment> )*
first-fragment ::= [a-z] <word>
| [A-Z] <acronym>
fragment ::= <word>
| <acronym>
word ::= [a-z] [0-9a-z]*
acronym ::= [A-Z] [0-9A-Z]*
word ::= [0-9a-z]*
acronym ::= [0-9A-Z]*
interfacename ::= <namespace> <label> <projection> <interfaceversion>?
| <namespace>+ <label> <projection>+ <interfaceversion>? 🪺
namespace ::= <words> ':'
Expand Down Expand Up @@ -2675,6 +2676,16 @@ mapped to `isXML`, `IsXml`, `is_XML` or `is_xml`, depending on the target
language/convention. The highly-restricted character set ensures that
capitalization is trivial and does not require consulting Unicode tables.

Based on the lexical definition of `label` above, the following are all valid
labels:
* `a`, `a-b-c`, `a1-2-3`, `A`, `A-B-C` and `A1-2-3` (but not `1-2-3`, since the
first fragment must start with a letter)
* `a11-w0rds`, `A11-4CR0NYMS` and `m1x3d-4CR0NYMS`

Technically, based on the definitions given, the `fragment` `2` (and `3`) in
`a1-2-3` is ambiguously either a `word` or an `acronym`, but the distinction
only relates to casing and numbers aren't cased.

Components provide two options for naming exports, symmetric to the first two
options for naming imports:
* a **plain name** that leaves it up to the developer to "read the docs"
Expand Down
19 changes: 19 additions & 0 deletions test/names/kebab.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(component (component
(import "a" (func))
(import "a1" (func))
(import "a-1" (func))
(import "a-1-b-2-c-3" (func))
(import "B" (func))
(import "B1" (func))
(import "B-1" (func))
(import "B-1-C-2-D-3" (func))
(import "a11-B11-123-ABC-abc" (func))
))
(assert_invalid
(component
(import "1" (func)))
"is not in kebab case")
(assert_invalid
(component
(import "1-a" (func)))
"is not in kebab case")
7 changes: 2 additions & 5 deletions test/wasm-tools/naming.wast
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
"instance 0 has no export named `Xml`"
)

(assert_invalid
(component
(type (flags "a-1-c"))
)
"flag name `a-1-c` is not in kebab case"
(component definition
(type (flags "a-1-c"))
)

(assert_invalid
Expand Down