]> Repositorios git - scryer-prolog.git/commitdiff
Line numbers start at 1
authorDavid Farrell <[email protected]>
Sat, 1 Feb 2025 19:02:34 +0000 (14:02 -0500)
committerDavid Farrell <[email protected]>
Sun, 2 Feb 2025 13:16:05 +0000 (08:16 -0500)
Bumps the line number for the singleton warning. When the singleton
occurs on the same line at the term starts, the line number is correct:

    foo(X).

However it stills mis-reports this line number as 1 instead of 5:

    foo(1) :-
        true,
        true,
        true,
        Y.

See issue #1356.

src/loader.pl
tests/scryer/cli/src_tests/directive_errors.md
tests/scryer/main.rs

index cf3c144834d744146c68d2a4c26525a20c8de423..12341b42ed298232a3a7b51bfb49e794ad4ad171 100644 (file)
@@ -210,7 +210,8 @@ load_loop(Stream, Evacuable) :-
        '$conclude_load'(Evacuable)
     ;  var(Term) ->
        instantiation_error(load/1)
-    ;  warn_about_singletons(Singletons, LinesRead),
+    ;  LineNum is LinesRead + 1,
+       warn_about_singletons(Singletons, LineNum),
        compile_term(Term, Evacuable),
        load_loop(Stream, Evacuable)
     ).
index 2beb7c73dd4f3a8c66d7f895124b10bfa3c8bf22..4b6c8b43bf0d5678204cd73582c206c9ebcf791c 100644 (file)
@@ -42,14 +42,14 @@ $ scryer-prolog -f --no-add-history tests-pl/invalid_decl7.pl -g halt
 
 ```trycmd
 $ scryer-prolog -f --no-add-history tests-pl/invalid_decl8.pl -g halt
-% Warning: singleton variables Var at line 0 of invalid_decl8.pl
+% Warning: singleton variables Var at line 1 of invalid_decl8.pl
    error(domain_error(operator_specifier,todo_insert_invalid_term_here),load/1).
 
 ```
 
 ```trycmd
 $ scryer-prolog -f --no-add-history tests-pl/invalid_decl9.pl -g halt
-% Warning: singleton variables Var at line 0 of invalid_decl9.pl
+% Warning: singleton variables Var at line 1 of invalid_decl9.pl
    error(type_error(integer,todo_insert_invalid_term_here),load/1).
 
 ```
@@ -63,7 +63,7 @@ FIXME I belive the following test should result in a `error(instantiation_error,
 
 ```trycmd
 $ scryer-prolog -f --no-add-history tests-pl/invalid_decl11.pl -g halt
-% Warning: singleton variables Var at line 0 of invalid_decl11.pl
+% Warning: singleton variables Var at line 1 of invalid_decl11.pl
    error(type_error(list,todo_insert_invalid_term_here),load/1).
 
 ```
@@ -101,7 +101,7 @@ $ scryer-prolog -f --no-add-history tests-pl/invalid_decl16.pl -g halt
 
 ```trycmd
 $ scryer-prolog -f --no-add-history tests-pl/invalid_decl_issue2467.pl -g halt
-% Warning: singleton variables D at line 0 of invalid_decl_issue2467.pl
+% Warning: singleton variables D at line 1 of invalid_decl_issue2467.pl
    error(instantiation_error,load/1).
 
 ```
index bb77f334b2f223e0bf7bf0c440253225bcafe7f6..a501bd423e79cf71c3ca4738efb884be88fa9bbc 100644 (file)
@@ -22,7 +22,6 @@ fn cli_tests() {
     trycmd::TestCases::new()
         .default_bin_name("scryer-prolog")
         .case("tests/scryer/cli/issues/*.toml")
-        .skip("tests/scryer/cli/issues/singleton_warning.toml") // wrong line number
         .case("tests/scryer/cli/src_tests/*.toml")
         .case("tests/scryer/cli/src_tests/*.md");
 }