File tree 4 files changed +91
-1
lines changed
fluent-syntax/test/fixtures_structure
4 files changed +91
-1
lines changed Original file line number Diff line number Diff line change
1
+ # ERROR No blanks are allowed between * and [.
2
+ err01 = { $sel ->
3
+ * [ key ] Value
4
+ }
5
+
6
+ # ERROR Missing default variant.
7
+ err02 = { $sel ->
8
+ [ key ] Value
9
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " Resource" ,
3
+ "body" : [
4
+ {
5
+ "type" : " Comment" ,
6
+ "content" : " ERROR No blanks are allowed between * and [." ,
7
+ "span" : {
8
+ "type" : " Span" ,
9
+ "start" : 0 ,
10
+ "end" : 46
11
+ }
12
+ },
13
+ {
14
+ "type" : " Junk" ,
15
+ "annotations" : [
16
+ {
17
+ "type" : " Annotation" ,
18
+ "code" : " E0011" ,
19
+ "args" : [],
20
+ "message" : " Expected at least one variant after \" ->\" " ,
21
+ "span" : {
22
+ "type" : " Span" ,
23
+ "start" : 69 ,
24
+ "end" : 69
25
+ }
26
+ }
27
+ ],
28
+ "content" : " err01 = { $sel ->\n * [key] Value\n }\n\n " ,
29
+ "span" : {
30
+ "type" : " Span" ,
31
+ "start" : 47 ,
32
+ "end" : 87
33
+ }
34
+ },
35
+ {
36
+ "type" : " Comment" ,
37
+ "content" : " ERROR Missing default variant." ,
38
+ "span" : {
39
+ "type" : " Span" ,
40
+ "start" : 87 ,
41
+ "end" : 119
42
+ }
43
+ },
44
+ {
45
+ "type" : " Junk" ,
46
+ "annotations" : [
47
+ {
48
+ "type" : " Annotation" ,
49
+ "code" : " E0010" ,
50
+ "args" : [],
51
+ "message" : " Expected one of the variants to be marked as default (*)" ,
52
+ "span" : {
53
+ "type" : " Span" ,
54
+ "start" : 154 ,
55
+ "end" : 154
56
+ }
57
+ }
58
+ ],
59
+ "content" : " err02 = { $sel ->\n [key] Value\n }\n " ,
60
+ "span" : {
61
+ "type" : " Span" ,
62
+ "start" : 120 ,
63
+ "end" : 156
64
+ }
65
+ }
66
+ ],
67
+ "span" : {
68
+ "type" : " Span" ,
69
+ "start" : 0 ,
70
+ "end" : 156
71
+ }
72
+ }
Original file line number Diff line number Diff line change @@ -367,7 +367,15 @@ export default class FluentResource extends Map {
367
367
variants [ count ++ ] = { key, value} ;
368
368
}
369
369
370
- return count > 0 ? { variants, star} : null ;
370
+ if ( count === 0 ) {
371
+ return null ;
372
+ }
373
+
374
+ if ( star === undefined ) {
375
+ throw new FluentError ( "Expected default variant" ) ;
376
+ }
377
+
378
+ return { variants, star} ;
371
379
}
372
380
373
381
function parseVariantKey ( ) {
Original file line number Diff line number Diff line change
1
+ {}
You can’t perform that action at this time.
0 commit comments