File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -408,4 +408,24 @@ describe("decode", () => {
408408 assertExists ( info . ranges [ 0 ] ) ;
409409 assertStrictEquals ( info . ranges [ 0 ] . originalScope , undefined ) ;
410410 } ) ;
411+
412+ it ( "throws for free GENERATED_RANGE_CALL_SITE items in strict mode" , ( ) => {
413+ const encoder = new ItemEncoder ( ) ;
414+ encoder . addUnsignedVLQs ( Tag . GENERATED_RANGE_CALL_SITE ) ;
415+ encoder . addSignedVLQs ( 0 , 0 , 0 ) . finishItem ( ) ;
416+ const map = createMap ( encoder . encode ( ) , [ ] ) ;
417+
418+ assertThrows ( ( ) => decode ( map , { mode : DecodeMode . STRICT } ) ) ;
419+ } ) ;
420+
421+ it ( "ignores free GENERATED_RANGE_CALL_SITE items in lax mode" , ( ) => {
422+ const encoder = new ItemEncoder ( ) ;
423+ encoder . addUnsignedVLQs ( Tag . GENERATED_RANGE_CALL_SITE ) ;
424+ encoder . addSignedVLQs ( 0 , 0 , 0 ) . finishItem ( ) ;
425+ const map = createMap ( encoder . encode ( ) , [ ] ) ;
426+
427+ const info = decode ( map , { mode : DecodeMode . LAX } ) ;
428+
429+ assertEquals ( info . ranges , [ ] ) ;
430+ } ) ;
411431} ) ;
Original file line number Diff line number Diff line change @@ -346,7 +346,9 @@ class Decoder {
346346 ) {
347347 const range = this . #rangeStack. at ( - 1 ) ;
348348 if ( ! range ) {
349- // TODO: Throw in strict mode.
349+ this . #throwInStrictMode(
350+ "Encountered GENERATED_RANGE_CALL_SITE without surrounding GENERATED_RANGE_START" ,
351+ ) ;
350352 return ;
351353 }
352354
You can’t perform that action at this time.
0 commit comments