Explorar o código

[lexer] don't lex comments in code strings

closes #7202
Simon Krajewski %!s(int64=7) %!d(string=hai) anos
pai
achega
ab2fb14d21
Modificáronse 3 ficheiros con 12 adicións e 1 borrados
  1. 1 1
      src/compiler/server.ml
  2. 4 0
      src/syntax/lexer.ml
  3. 7 0
      tests/unit/src/unit/issues/Issue7207.hx

+ 1 - 1
src/compiler/server.ml

@@ -286,7 +286,7 @@ let rec wait_loop process_params verbose accept =
 					check_module_shadowing mctx.Typecore.com (get_changed_directories mctx) m
 			in
 			let has_policy policy = List.mem policy m.m_extra.m_check_policy || match policy with
-				| NoCheckShadowing | NoCheckFileTimeModification when !ServerConfig.do_not_check_modules -> true
+				| NoCheckShadowing | NoCheckFileTimeModification when !ServerConfig.do_not_check_modules && ctx.com.display.dms_kind <> DMNone -> true
 				| _ -> false
 			in
 			let check_file () =

+ 4 - 0
src/syntax/lexer.ml

@@ -443,7 +443,11 @@ and code_string lexbuf open_braces =
 		code_string lexbuf open_braces
 	| "/*" ->
 		let pmin = lexeme_start lexbuf in
+		let save = contents() in
+		reset();
 		(try ignore(comment lexbuf) with Exit -> error Unclosed_comment pmin);
+		reset();
+		Buffer.add_string buf save;
 		code_string lexbuf open_braces
 	| "//", Star (Compl ('\n' | '\r')) -> store lexbuf; code_string lexbuf open_braces
 	| Plus (Compl ('/' | '"' | '\'' | '{' | '}' | '\n' | '\r')) -> store lexbuf; code_string lexbuf open_braces

+ 7 - 0
tests/unit/src/unit/issues/Issue7207.hx

@@ -0,0 +1,7 @@
+package unit.issues;
+
+class Issue7207 extends unit.Test {
+	function test() {
+		eq("Haxe is great! 1", 'Haxe is great! ${/*13*/1}');
+	}
+}