Commit 77f46403 authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

Add a warning message for undefined parameters

parent c35164b8
......@@ -728,6 +728,7 @@ determine_boundary(X, 0, 1.0Inf) :-
determine_boundary(X, Low, 1.0Inf) :- % undefined parameter
atom(X),
!,
parameters:warning_parameter(X),
get_option(precision, Pre),
Low is 10^(- Pre).
......
......@@ -2,6 +2,8 @@
:- begin_tests(arithmetic_rules, [setup((clear_model, reset_options))]).
user:message_hook(undefined_parameter(_Name), warning, _). % block the Warning print_message
test('simplify1', []) :-
simplify(a+2*a, 3*a),
simplify(-1*a/b+2*a/b, a/b).
......@@ -30,8 +32,12 @@ test('always_positive_negative', []) :-
always_positive(a/(a+1)),
always_positive((2+a)*0),
always_negative((2+a)*0),
always_positive((x-1)^k1),
true.
always_positive((x-1)^k1).
test('always_positive_warning', [true(Warnings == 1)]) :-
set_counter(warnings, 0),
always_positive(w),
count(warnings, Warnings).
test('is_null', []) :-
is_null(a*0*1/2),
......
......@@ -239,6 +239,7 @@ clear_model :-
retractall(nusmv:query_molecules(_)),
set_counter(molecule_id, 0),
set_counter(parameter_id, 1),
nb_setval(troubler, []),
assertz(nusmv:query_molecules([])).
......
......@@ -9,14 +9,14 @@
parameter_value/2,
list_model_parameters/0,
set_parameter/2,
set_parameters/1
set_parameters/1,
warning_parameter/1
]
).
% Only for separate compilation/linting
:- use_module(doc).
:- devdoc('\\section{Commands}').
......@@ -93,3 +93,23 @@ set_parameters([]).
set_parameters([Parameter = Value | Tail]) :-
set_parameter(Parameter, Value),
set_parameters(Tail).
%! warning_parameter(Name)
%
% Raise a unique warning for undefined parameter
warning_parameter(Name) :-
catch(
nb_getval(troubler, List),
error(existence_error(variable,troubler),_Context),
List = []
),
(
member(Name, List)
->
true
;
append([Name], List, NewList),
nb_setval(troubler, NewList),
print_message(warning, undefined_parameter(Name))
).
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment