Fix extra slash at end of path

This commit is contained in:
imaqtkatt 2024-01-31 14:45:58 -03:00
parent 2b3ec9853a
commit 29177fa52d
10 changed files with 14 additions and 15 deletions

View File

@ -64,9 +64,8 @@ pub fn error_to_msg(err: &Rich<'_, Token>, code: &str, path: &Path) -> String {
RichReason::Many(errs) => &errs[0],
_ => err.reason(),
};
let mut path = path.to_path_buf();
path.push(format!(":{lin}:{col}"));
format!("At {}: {}\n{}", path.display(), reason, highlight_error::highlight_error(start, end, code))
let path = format!("{}:{lin}:{col}", path.display());
format!("At {}: {}\n{}", path, reason, highlight_error::highlight_error(start, end, code))
}
fn line_and_col_of_byte(until: usize, src: &str) -> (usize, usize) {

View File

@ -2,5 +2,5 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/just_a_name.hvm
---
At tests/golden_tests/compile_file/just_a_name.hvm/:1:1: found 'asdf' expected '+', '(', '[', or '='
At tests/golden_tests/compile_file/just_a_name.hvm:1:1: found 'asdf' expected '+', '(', '[', or '='
 1 | asdf

View File

@ -2,5 +2,5 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file_o_all/adt_string.hvm
---
At tests/golden_tests/compile_file_o_all/adt_string.hvm/:1:1: String is a built-in datatype and should not be overridden.
At tests/golden_tests/compile_file_o_all/adt_string.hvm:1:1: String is a built-in datatype and should not be overridden.
 1 | data String = S

View File

@ -2,5 +2,5 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/missing_paren.hvm
---
At tests/golden_tests/parse_file/missing_paren.hvm/:1:7: Missing Parenthesis around rule body
At tests/golden_tests/parse_file/missing_paren.hvm:1:7: Missing Parenthesis around rule body
 1 | main = * *

View File

@ -2,5 +2,5 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/missing_paren_then_adt.hvm
---
At tests/golden_tests/parse_file/missing_paren_then_adt.hvm/:1:7: Missing Parenthesis around rule body
At tests/golden_tests/parse_file/missing_paren_then_adt.hvm:1:7: Missing Parenthesis around rule body
 1 | main = * * * *

View File

@ -2,7 +2,7 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/multiple_parsing_errors.hvm
---
At tests/golden_tests/parse_file/multiple_parsing_errors.hvm/:3:7: Missing Parenthesis around rule body
At tests/golden_tests/parse_file/multiple_parsing_errors.hvm:3:7: Missing Parenthesis around rule body
 3 | main = A B
At tests/golden_tests/parse_file/multiple_parsing_errors.hvm/:5:0: Repeated datatype 'Foo'
At tests/golden_tests/parse_file/multiple_parsing_errors.hvm:5:0: Repeated datatype 'Foo'
 5 | data Foo = B

View File

@ -2,5 +2,5 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/parse_file/repeated_adt_name.hvm
---
At tests/golden_tests/parse_file/repeated_adt_name.hvm/:2:0: Repeated datatype 'Foo'
At tests/golden_tests/parse_file/repeated_adt_name.hvm:2:0: Repeated datatype 'Foo'
 2 | data Foo = B

View File

@ -2,9 +2,9 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/names_hyphen_toplevel.hvm
---
At tests/golden_tests/run_file/names_hyphen_toplevel.hvm/:1:1: Names with '-' are not supported at top level.
At tests/golden_tests/run_file/names_hyphen_toplevel.hvm:1:1: Names with '-' are not supported at top level.
 1 | this-is-not-allowed = 1
At tests/golden_tests/run_file/names_hyphen_toplevel.hvm/:3:5: Names with '-' are not supported at top level.
At tests/golden_tests/run_file/names_hyphen_toplevel.hvm:3:5: Names with '-' are not supported at top level.
 3 | data Foo-Bar = Baz-Qux
At tests/golden_tests/run_file/names_hyphen_toplevel.hvm/:3:15: Names with '-' are not supported at top level.
At tests/golden_tests/run_file/names_hyphen_toplevel.hvm:3:15: Names with '-' are not supported at top level.
 3 | data Foo-Bar = Baz-Qux

View File

@ -2,6 +2,6 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/override_list_ctr.hvm
---
At tests/golden_tests/run_file/override_list_ctr.hvm/:1:1: LNil is a built-in constructor and should not be overridden.
At tests/golden_tests/run_file/override_list_ctr.hvm:1:1: LNil is a built-in constructor and should not be overridden.
 1 | data Override
 2 |  = LNil

View File

@ -2,6 +2,6 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/override_str_ctr.hvm
---
At tests/golden_tests/run_file/override_str_ctr.hvm/:1:1: SCons is a built-in constructor and should not be overridden.
At tests/golden_tests/run_file/override_str_ctr.hvm:1:1: SCons is a built-in constructor and should not be overridden.
 1 | data Override
 2 |  = (SCons any)