core.match

IllegalArgumentException when AOT compiling namespace using clojure.core.match since alpha10

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    core.match 0.2.0-alpha10 and 0.2.0-alpha11-SNAPSHOT (git 7ad66cc)
    clojure 1.3.0 and 1.4.0

Description

Getting this when AOT compiling a trivial project (attached) using alpha10: (works fine with alpha9)

Caused by: java.lang.IllegalArgumentException: No method in multimethod 'to-source' for dispatch value: class clojure.core.match.WildcardPattern
	at clojure.lang.MultiFn.getFn(MultiFn.java:121)
	at clojure.lang.MultiFn.invoke(MultiFn.java:167)
	at clojure.core.match$dag_clause_to_clj.invoke(match.clj:424)
	at clojure.lang.AFn.applyToHelper(AFn.java:167)
	at clojure.lang.AFn.applyTo(AFn.java:151)
	at clojure.core$apply.invoke(core.clj:602)
	at clojure.lang.AFn.applyToHelper(AFn.java:167)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.core$apply.invoke(core.clj:604)
	at clojure.core$partial$fn__3796.doInvoke(core.clj:2343)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$map$fn__3811.invoke(core.clj:2430)
	at clojure.lang.LazySeq.sval(LazySeq.java:42)
	at clojure.lang.LazySeq.seq(LazySeq.java:60)
	at clojure.lang.RT.seq(RT.java:466)
	at clojure.core$seq.invoke(core.clj:133)
	at clojure.core$apply.invoke(core.clj:600)
	at clojure.core$mapcat.doInvoke(core.clj:2459)
	at clojure.lang.RestFn.invoke(RestFn.java:423)
	at clojure.core.match.SwitchNode.n_to_clj(match.clj:446)
	at clojure.core.match.BindNode.n_to_clj(match.clj:411)
	at clojure.core.match$executable_form.invoke(match.clj:1713)
	at clojure.core.match$clj_form.invoke(match.clj:1721)
	at clojure.core.match$match.doInvoke(match.clj:1750)

Activity

Hide
David Nolen added a comment -

as far as I can tell, this is the same issue as MATCH-53 which is resolved in master. Unless I hear otherwise, I'm closing this one.

Show
David Nolen added a comment - as far as I can tell, this is the same issue as MATCH-53 which is resolved in master. Unless I hear otherwise, I'm closing this one.
Hide
Tim Olsen added a comment -

I've seen this problem as well. If I try to compile a second time, however, without running lein clean, the compilation succeeds. Maybe it's a bootstrapping problem?

Show
Tim Olsen added a comment - I've seen this problem as well. If I try to compile a second time, however, without running lein clean, the compilation succeeds. Maybe it's a bootstrapping problem?
Hide
Paudi Moriarty added a comment - - edited

This seems to do it:

(match {}
  {:a :x :b b} :dummy
  :else :dummy)
Show
Paudi Moriarty added a comment - - edited This seems to do it:
(match {}
  {:a :x :b b} :dummy
  :else :dummy)
Hide
David Nolen added a comment -

Can you include an example pattern which works under normal circumstances but fails under AOT? This must meant that WildcardPatterns are making it through under AOT and getting to the multimethod case but not under incremental compilation at the REPL.

Show
David Nolen added a comment - Can you include an example pattern which works under normal circumstances but fails under AOT? This must meant that WildcardPatterns are making it through under AOT and getting to the multimethod case but not under incremental compilation at the REPL.
Hide
Paudi Moriarty added a comment - - edited

So the pattern parameter being passed to dag-clause-to-clj:

(defn dag-clause-to-clj [occurrence pattern action]
  (let [test (if (instance? clojure.core.match.IPatternCompile pattern)
               (to-source* pattern occurrence)
               (to-source pattern occurrence))]
...

is a WildcardPattern which doesn't implement IPatternCompile and doesn't have a to-source method. So it seems it shouldn't be passed at all. Indeed, in normal usage it isn't.

;; ## Wildcard Pattern
;; 
;; A wildcard pattern accepts any value.
;;
;; In practice, the DAG compilation eliminates any wildcard patterns.

(defprotocol IWildcardPattern
  (sym [this]))

(deftype WildcardPattern [sym _meta]
  IWildcardPattern
  (sym [_] sym)
  clojure.lang.IObj
  (meta [_] _meta)
  (withMeta [_ new-meta]
    (WildcardPattern. sym new-meta))
  Object
  (toString [_]
    (str sym)))
Show
Paudi Moriarty added a comment - - edited So the pattern parameter being passed to dag-clause-to-clj:
(defn dag-clause-to-clj [occurrence pattern action]
  (let [test (if (instance? clojure.core.match.IPatternCompile pattern)
               (to-source* pattern occurrence)
               (to-source pattern occurrence))]
...
is a WildcardPattern which doesn't implement IPatternCompile and doesn't have a to-source method. So it seems it shouldn't be passed at all. Indeed, in normal usage it isn't.
;; ## Wildcard Pattern
;; 
;; A wildcard pattern accepts any value.
;;
;; In practice, the DAG compilation eliminates any wildcard patterns.

(defprotocol IWildcardPattern
  (sym [this]))

(deftype WildcardPattern [sym _meta]
  IWildcardPattern
  (sym [_] sym)
  clojure.lang.IObj
  (meta [_] _meta)
  (withMeta [_ new-meta]
    (WildcardPattern. sym new-meta))
  Object
  (toString [_]
    (str sym)))
Hide
Paudi Moriarty added a comment -

Thanks David,

That change has not fixed the issue for me.

Show
Paudi Moriarty added a comment - Thanks David, That change has not fixed the issue for me.
Hide
David Nolen added a comment - - edited

I believe I may have found the cause and have fixed master - if someone can confirm I'll happily cut another release.

http://github.com/clojure/core.match/commit/cbcc6e5fa070a7025e72f5eab4e83eaec100332b

Show
David Nolen added a comment - - edited I believe I may have found the cause and have fixed master - if someone can confirm I'll happily cut another release. http://github.com/clojure/core.match/commit/cbcc6e5fa070a7025e72f5eab4e83eaec100332b
Hide
Frederik De Bleser added a comment -

I can confirm the same issue on alpha11.

Show
Frederik De Bleser added a comment - I can confirm the same issue on alpha11.

People

Vote (3)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: