Skip to content

Commit

Permalink
Merge pull request #2259 from bakaq/comment_warnings
Browse files Browse the repository at this point in the history
Emit warnings as Prolog comments
  • Loading branch information
mthom committed Jan 1, 2024
2 parents d713456 + d9d90d1 commit 1f90dbe
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/loader.pl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
( call(Goal) ->
true
; %% initialization goals can fail without thwarting the load.
write('Warning: initialization/1 failed for: '),
write('% Warning: initialization/1 failed for: '),
writeq(Goal),
nl
).
Expand Down Expand Up @@ -188,7 +188,7 @@
warn_about_singletons([Singleton|Singletons], LinesRead) :-
( filter_anonymous_vars([Singleton|Singletons], VarEqs),
VarEqs \== [] ->
write('Warning: singleton variables '),
write('% Warning: singleton variables '),
print_comma_separated_list(VarEqs),
write(' at line '),
write(LinesRead),
Expand Down Expand Up @@ -286,7 +286,7 @@

print_goal_expansion_warning(Pred) :-
nl,
write('Warning: clause body goal expansion failed because '),
write('% Warning: clause body goal expansion failed because '),
writeq(Pred),
write(' is not callable.'),
nl.
Expand Down
4 changes: 2 additions & 2 deletions src/machine/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ fn print_overwrite_warning(
}

println!(
"Warning: overwriting {}/{} because the clauses are discontiguous",
"% Warning: overwriting {}/{} because the clauses are discontiguous",
key.0.as_str(),
key.1
);
Expand Down Expand Up @@ -2179,7 +2179,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
if is_cross_module_clause && !local_predicate_info.is_extensible {
if predicate_info.is_multifile {
println!(
"Warning: overwriting multifile predicate {}:{}/{} because \
"% Warning: overwriting multifile predicate {}:{}/{} because \
it was not locally declared multifile.",
self.payload.predicates.compilation_target,
key.0.as_str(),
Expand Down
2 changes: 1 addition & 1 deletion src/machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ impl Machine {
}
Unknown::Warn => {
println!(
"warning: predicate {}/{} is undefined",
"% Warning: predicate {}/{} is undefined",
name.as_str(),
arity
);
Expand Down
6 changes: 3 additions & 3 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl ReadlineStream {
if let Some(mut path) = dirs_next::home_dir() {
path.push(HISTORY_FILE);
if path.exists() && rl.load_history(&path).is_err() {
println!("Warning: loading history failed");
println!("% Warning: loading history failed");
}
}

Expand Down Expand Up @@ -213,10 +213,10 @@ impl ReadlineStream {
path.push(HISTORY_FILE);
if path.exists() {
if self.rl.append_history(&path).is_err() {
println!("Warning: couldn't append history (existing file)");
println!("% Warning: couldn't append history (existing file)");
}
} else if self.rl.save_history(&path).is_err() {
println!("Warning: couldn't save history (new file)");
println!("% Warning: couldn't save history (new file)");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/toplevel.pl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
write_term(Exception, [double_quotes(DQ)]), nl % halt?
)
) -> true
; write('Warning: initialization failed for: '),
; write('% Warning: initialization failed for: '),
write_term(Goal, [variable_names(VNs),double_quotes(DQ)]), nl
),
run_goals(Goals).
Expand Down
2 changes: 1 addition & 1 deletion tests/scryer/cli/issues/singleton_warning.stdout
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Warning: singleton variables X at line 4 of singleton_example.pl
% Warning: singleton variables X at line 4 of singleton_example.pl
true.

0 comments on commit 1f90dbe

Please sign in to comment.