Open maowtm opened 2 years ago
Can you elaborate on this?
Basically I had a config
predicate that defined some config corresponding to variants, like:
config("default", "make all").
config("32bit", "make 32bit").
etc...
And I use it like this:
redis(version, variant) :-
...
config(variant, make_cmd),
...
run(make_cmd).
However, there was a special case for when variant = "alpine", so I copy-pasted the definition for redis
and added this:
redis(version, "alpine") :-
...
config(variant, make_cmd),
...
run(make_cmd).
I thought it would be alright to just replace the "variant" variable with "alpine"
, and I thought I have replaced all the "variant" variable, but it turns out I forgot to replace the "variant" in the config line, so the result is that it arbitrarily chose a make_cmd, and because it is quite deep inside a merge I did not notice that, so was wondering why things won't compile...
I was thinking about a warning when there are multiple valid choices for a predicate. This would also prevent mistake like
foo(bar) :- (bar = "1"; bar = "2"), do_things_specific_for_1_and_2.
foo(bar) :- bar != "1", do_things_for_anything_else. # did not cover the case where bar = "2".
When we add some kind of cost-based selection later maybe we could limit this warning to just logic predicates...
Just spent 3 hour on a simple mistake caused by an accidentally unbounded variable.