Skip to content

Commit

Permalink
fix: fix rule loading tests and fact loading handling of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
k13gomez committed Mar 10, 2024
1 parent f4aca0f commit c15d991
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main/clojure/clara/rules.clj
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
(mapcat com/load-facts-from-source @resolved)

:else
(throw (ex-info (str "The source referenced by " sym " is not valid.") {:sym sym}))))
[]))

;; The symbol is not qualified, so treat it as a namespace.
(->> (ns-interns sym)
Expand Down Expand Up @@ -194,7 +194,7 @@
(mapcat com/load-hierarchies-from-source @resolved)

:else
(throw (ex-info (str "The source referenced by " sym " is not valid.") {:sym sym}))))
[]))

;; The symbol is not qualified, so treat it as a namespace.
(->> (ns-interns sym)
Expand Down Expand Up @@ -228,7 +228,7 @@
(mapcat com/load-rules-from-source @resolved)

:else
(throw (ex-info (str "The source referenced by " sym " is not valid.") {:sym sym}))))
[]))

;; The symbol is not qualified, so treat it as a namespace.
(->> (ns-interns sym)
Expand Down
9 changes: 6 additions & 3 deletions src/main/clojure/clara/rules/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
(defn- md5-hash
"Returns the md5 digest of the given data after converting it to a string"
[x]
(digest/md5 ^String (str x)))
(digest/md5 ^String (pr-str x)))

(defn- is-variable?
"Returns true if the given expression is a variable (a symbol prefixed by ?)"
Expand Down Expand Up @@ -2178,10 +2178,13 @@
(var? source)
(load-facts-from-source @source)

(:hierarchy-data source)
(fn? source) ;;; source is a rule fn so it can't also be a fact unless explicitly inserted
[]

(:lhs source)
(:hierarchy-data source) ;;; source is a hierarchy so it can't also be a fact unless explicitly inserted
[]

(:lhs source) ;;; source is a production so it can't also be a fact unless explicitly inserted
[]

:else [source]))
Expand Down

0 comments on commit c15d991

Please sign in to comment.