clara-rules icon indicating copy to clipboard operation
clara-rules copied to clipboard

Duplicate result bindings in rules should cause an exception

Open WilliamParker opened this issue 9 years ago • 1 comments

The following rule compiles and a session with it executes:

(defrule sample-should-fail-rule
                    [?binding <- Cold]
                    [?binding <- Hot]
                    =>
                    (insert! (->LousyWeather)))

This repetition of result bindings between different conditions seems fundamentally nonsensical to me. I found a case in our codebase where we had rules like this being automatically generated. Obviously this is a defect in our code's use of Clara, but ideally Clara wouldn't accept rules like this even if users mistakenly create them.

WilliamParker avatar Nov 22 '16 14:11 WilliamParker

+1

devn avatar Jan 07 '17 02:01 devn

As noted on https://github.com/cerner/clara-rules/pull/467#issuecomment-788699735 it looks like the engine did have behaviour, that while arguably undesirable, isn't exactly nonsensical - equality between the duplicated bindings does seem to be enforced. In terms of linting, I think any enhancements can be added in the clj-kondo hooks added in https://github.com/cerner/clara-rules/pull/482 ; a separate linting layer seems superfluous in my opinion. I'm closing this issue and the PR https://github.com/cerner/clara-rules/pull/467 but we can discuss if there is disagreement. In any case the PR has been stale for over 2 years now.

WilliamParker avatar Jun 11 '23 15:06 WilliamParker