diff --git a/src/integration.rs b/src/integration.rs index a28ac8d..f18a5fe 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -1614,3 +1614,17 @@ echo A B C: stderr: "echo --some --awesome --flags\n", status: EXIT_SUCCESS, } + +integration_test! { + name: comment_before_variable, + justfile: " +# +A='1' +echo: + echo {{A}} + ", + args: ("echo"), + stdout: "1\n", + stderr: "echo 1\n", + status: EXIT_SUCCESS, +} diff --git a/src/lib.rs b/src/lib.rs index 216ad4d..71a5d7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1528,7 +1528,7 @@ fn tokenize(text: &str) -> Result, CompileError> { static ref BACKTICK: Regex = token(r"`[^`\n\r]*`" ); static ref COLON: Regex = token(r":" ); static ref AT: Regex = token(r"@" ); - static ref COMMENT: Regex = token(r"#([^!].*)?$" ); + static ref COMMENT: Regex = token(r"#([^!\n\r].*)?$" ); static ref EOF: Regex = token(r"(?-m)$" ); static ref EOL: Regex = token(r"\n|\r\n" ); static ref EQUALS: Regex = token(r"=" ); diff --git a/src/unit.rs b/src/unit.rs index de7e695..1958b08 100644 --- a/src/unit.rs +++ b/src/unit.rs @@ -156,6 +156,17 @@ hello: tokenize_success(text, "$#$N:$>^_$^_$$^_$$^_$$<#$."); } +#[test] +fn tokenize_comment_before_variable() { + let text = " +# +A='1' +echo: + echo {{A}} + "; + tokenize_success(text, "$#$N='$N:$>^_{N}$<."); +} + #[test] fn tokenize_interpolation_backticks() { tokenize_success(