File tree Expand file tree Collapse file tree 7 files changed +72
-4
lines changed Expand file tree Collapse file tree 7 files changed +72
-4
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ impl Gen for Hashbang<'_> {
6868
6969impl Gen for Directive < ' _ > {
7070 fn r#gen ( & self , p : & mut Codegen , _ctx : Context ) {
71+ p. print_comments_at ( self . span . start ) ;
7172 p. add_source_mapping ( self . span ) ;
7273 p. print_indent ( ) ;
7374 // A Use Strict Directive may not contain an EscapeSequence or LineContinuation.
Original file line number Diff line number Diff line change @@ -224,6 +224,8 @@ pub mod legal {
224224* @preserve
225225*/
226226" ,
227+ // Issue #14953: legal comments above directives
228+ "/*!\n * legal comment\n */\n \n \" use strict\" ;\n \n export const foo = 'foo';" ,
227229 ]
228230 }
229231
Original file line number Diff line number Diff line change 11-- -
2- source : crates / oxc_codegen / tests / integration / main .rs
2+ source : crates / oxc_codegen / tests / integration / tester .rs
33-- -
44########## 0
55/* @license */
@@ -127,3 +127,19 @@ function foo() {
127127/**
128128* @preserve
129129*/
130+
131+ ########## 9
132+ /* !
133+ * legal comment
134+ */
135+
136+ " use strict" ;
137+
138+ export const foo = ' foo' ;
139+ ----------
140+ ' use strict' ;
141+ export const foo = ' foo' ;
142+
143+ /* !
144+ * legal comment
145+ */
Original file line number Diff line number Diff line change 11-- -
2- source : crates / oxc_codegen / tests / integration / main .rs
2+ source : crates / oxc_codegen / tests / integration / tester .rs
33-- -
44########## 0
55/* @license */
@@ -109,3 +109,17 @@ function foo(){(()=>{
109109/**
110110* @preserve
111111*/
112+
113+ ########## 9
114+ /* !
115+ * legal comment
116+ */
117+
118+ " use strict" ;
119+
120+ export const foo = ' foo' ;
121+ ----------
122+ ' use strict' ;export const foo= ` foo` ;
123+ /* !
124+ * legal comment
125+ */
Original file line number Diff line number Diff line change 11-- -
2- source : crates / oxc_codegen / tests / integration / main .rs
2+ source : crates / oxc_codegen / tests / integration / tester .rs
33-- -
44########## 0
55/* @license */
@@ -112,3 +112,18 @@ function foo() {
112112/**
113113* @preserve
114114*/
115+
116+ ########## 9
117+ /* !
118+ * legal comment
119+ */
120+
121+ " use strict" ;
122+
123+ export const foo = ' foo' ;
124+ ----------
125+ /* !
126+ * legal comment
127+ */
128+ ' use strict' ;
129+ export const foo = ' foo' ;
Original file line number Diff line number Diff line change 11-- -
2- source : crates / oxc_codegen / tests / integration / main .rs
2+ source : crates / oxc_codegen / tests / integration / tester .rs
33-- -
44########## 0
55/* @license */
@@ -108,3 +108,16 @@ function foo() {
108108*/
109109
110110/* ! For license information please see test.js */
111+ ########## 9
112+ /* !
113+ * legal comment
114+ */
115+
116+ " use strict" ;
117+
118+ export const foo = ' foo' ;
119+ ----------
120+ ' use strict' ;
121+ export const foo = ' foo' ;
122+
123+ /* ! For license information please see test.js */
Original file line number Diff line number Diff line change 2121 throw new Error ()
2222 ^
2323
24+
2425Error
2526 at fn (/ project / input .js :3 :11 )
2627 at <anonymous > (/ project / input .js :5 :1 )
@@ -48,6 +49,7 @@ obj.fn();
4849 throw new Error ()
4950 ^
5051
52+
5153Error
5254 at Object .fn (/ project / input .js :4 :15 )
5355 at <anonymous > (/ project / input .js :7 :5 )
@@ -77,6 +79,7 @@ obj.obj2.fn();
7779 throw new Error ()
7880 ^
7981
82+
8083Error
8184 at Object .fn (/ project / input .js :5 :19 )
8285 at <anonymous > (/ project / input .js :9 :10 )
@@ -108,6 +111,7 @@ obj.fn()();
108111 throw new Error ()
109112 ^
110113
114+
111115Error
112116 at fn2 (/ project / input .js :5 :19 )
113117 at <anonymous > (/ project / input .js :9 :9 )
@@ -139,6 +143,7 @@ obj.fn([1])();
139143 throw new Error ()
140144 ^
141145
146+
142147Error
143148 at <anonymous > (/ project / input .js :5 :19 )
144149 at <anonymous > (/ project / input .js :9 :12 )
@@ -172,6 +177,7 @@ obj.fn({ a })();
172177 throw new Error ()
173178 ^
174179
180+
175181Error
176182 at <anonymous > (/ project / input .js :6 :19 )
177183 at <anonymous > (/ project / input .js :10 :12 )
@@ -201,6 +207,7 @@ fn("name", () => {
201207 throw new Error ()
202208 ^
203209
210+
204211Error
205212 at <anonymous > (/ project / input .js :6 :11 )
206213 at fn (/ project / input .js :2 :5 )
You can’t perform that action at this time.
0 commit comments