File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed
crates/wasmparser/src/validator
snapshots/local/component-model/naming.wast Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -627,9 +627,9 @@ impl<'a> ComponentNameParser<'a> {
627
627
// pkgpath ::= <namespace>+ <label> <projection>*
628
628
fn pkg_path ( & mut self , require_projection : bool ) -> Result < ( ) > {
629
629
// There must be at least one package namespace
630
- self . take_kebab ( ) ?;
630
+ self . take_lowercase_kebab ( ) ?;
631
631
self . expect_str ( ":" ) ?;
632
- self . take_kebab ( ) ?;
632
+ self . take_lowercase_kebab ( ) ?;
633
633
634
634
if self
635
635
. features
@@ -638,7 +638,7 @@ impl<'a> ComponentNameParser<'a> {
638
638
// Take the remaining package namespaces and name
639
639
while self . next . starts_with ( ':' ) {
640
640
self . expect_str ( ":" ) ?;
641
- self . take_kebab ( ) ?;
641
+ self . take_lowercase_kebab ( ) ?;
642
642
}
643
643
}
644
644
@@ -823,6 +823,17 @@ impl<'a> ComponentNameParser<'a> {
823
823
. unwrap_or_else ( || self . expect_kebab ( ) )
824
824
}
825
825
826
+ fn take_lowercase_kebab ( & mut self ) -> Result < & ' a KebabStr > {
827
+ let kebab = self . take_kebab ( ) ?;
828
+ if let Some ( c) = kebab. chars ( ) . find ( |c| * c != '-' && !c. is_lowercase ( ) ) {
829
+ bail ! (
830
+ self . offset,
831
+ "character `{c}` is not lowercase in package name/namespace"
832
+ ) ;
833
+ }
834
+ Ok ( kebab)
835
+ }
836
+
826
837
fn expect_kebab ( & mut self ) -> Result < & ' a KebabStr > {
827
838
let s = self . take_rest ( ) ;
828
839
self . kebab ( s)
Original file line number Diff line number Diff line change 97
97
)
98
98
" `DOWn` is not in kebab case"
99
99
)
100
+
101
+ (assert_invalid
102
+ (component
103
+ (instance (import " A:b/c" ))
104
+ )
105
+ " character `A` is not lowercase in package name/namespace"
106
+ )
107
+ (assert_invalid
108
+ (component
109
+ (instance (import " a:B/c" ))
110
+ )
111
+ " character `B` is not lowercase in package name/namespace"
112
+ )
113
+ (component
114
+ (instance (import " a:b/c" ))
115
+ )
Original file line number Diff line number Diff line change
1
+ (component
2
+ (type (;0;)
3
+ (instance)
4
+ )
5
+ (import "a:b/c" (instance (;0;) (type 0)))
6
+ )
You can’t perform that action at this time.
0 commit comments