File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -237,4 +237,24 @@ describe("decode", () => {
237
237
238
238
assertEquals ( info . scopes , [ ] ) ;
239
239
} ) ;
240
+
241
+ it ( "throws for free GENERATED_RANGE_BINDINGS items in strict mode" , ( ) => {
242
+ const encoder = new ItemEncoder ( ) ;
243
+ encoder . addUnsignedVLQs ( Tag . GENERATED_RANGE_BINDINGS ) ;
244
+ encoder . addSignedVLQs ( 0 , - 1 ) . finishItem ( ) ;
245
+ const map = createMap ( encoder . encode ( ) , [ "foo" ] ) ;
246
+
247
+ assertThrows ( ( ) => decode ( map , { mode : DecodeMode . STRICT } ) ) ;
248
+ } ) ;
249
+
250
+ it ( "ignores free ORIGINAL_SCOPE_VARIABLES items in loose mode" , ( ) => {
251
+ const encoder = new ItemEncoder ( ) ;
252
+ encoder . addUnsignedVLQs ( Tag . GENERATED_RANGE_BINDINGS ) ;
253
+ encoder . addSignedVLQs ( 0 , - 1 ) . finishItem ( ) ;
254
+ const map = createMap ( encoder . encode ( ) , [ "foo" ] ) ;
255
+
256
+ const info = decode ( map , { mode : DecodeMode . LOOSE } ) ;
257
+
258
+ assertEquals ( info . scopes , [ ] ) ;
259
+ } ) ;
240
260
} ) ;
Original file line number Diff line number Diff line change @@ -230,9 +230,10 @@ class Decoder {
230
230
case Tag . GENERATED_RANGE_BINDINGS : {
231
231
const range = this . #rangeStack. at ( - 1 ) ;
232
232
if ( ! range ) {
233
- throw new Error (
233
+ this . #throwInStrictMode (
234
234
"Encountered GENERATED_RANGE_BINDINGS without surrounding GENERATED_RANGE_START" ,
235
235
) ;
236
+ continue ;
236
237
}
237
238
238
239
for ( const valueIdx of item . valueIdxs ) {
You can’t perform that action at this time.
0 commit comments