<< Back to previous view

[CLJS-1644] Recursive protocol method for a record never terminates Created: 23/May/16  Updated: 23/May/16

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: 1.7.228
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Brian Stiles Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Any



 Description   

When extending a protocol for a record, a recursive method can never terminate in some cases.

(defrecord R [a])

(defprotocol P
  (f [x]))

(extend-protocol P
  R
  (f [x]
    (if x
      (recur nil)
      x))
  default
  (f [x]
    (if x
      (recur nil)
      x)))

(prn (f 1))        ; #1
(prn (f (R. 1)))   ; #2

prn call #1 prints nil as expected, but prn call #2 never terminates.

It looks like the compiler creates a variable assigned to this within the while loop such that the test of "x" is always really testing this when it should be testing the value of x passed in by the call to recur.

Note, I'm testing ClojureScript 1.8.51. The "Affects Version/s" field above only gives 1.7.228 as the most recent version.



 Comments   
Comment by Brian Stiles [ 23/May/16 4:14 AM ]

Actually, "always really testing 'this' when it should be testing the value of x passed in by the call to recur" is only true if the type of the value represented by x remains the same. If, as in the example, the type changes, the call should be dispatched to the properly matching method implementation.

This seems to behave as expected in Clojure.





[CLJS-1643] Emit more informative error when emitting a type which has no emit multimethod case Created: 21/May/16  Updated: 21/May/16

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: David Nolen Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Users may accidentally splice in Clojure functions and other things in macros that work in Clojure which cannot work in ClojureScript. We may want to include a default warning for the most common/likely error cases.






[CLJS-1642] cljs.core/reductions does not respect 'reduced'. Created: 21/May/16  Updated: 21/May/16  Resolved: 21/May/16

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: 1.7.228
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Brian Stiles Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None
Environment:

Any



 Description   

The following should return ([] [1] [1 2] [1 2 3] :stop) but throws an exception because the cljs.core/Reduced instance is passed to conj.

(reductions
(fn [xs x]
(if (= 4 x)
(reduced :stop)
(conj xs x)))
[] [1 2 3 4 5])

Same problem as existed in Clojure: http://dev.clojure.org/jira/browse/CLJ-1185

The fix in the patch attached to CLJ-1185 should suffice.



 Comments   
Comment by David Nolen [ 21/May/16 5:02 PM ]

fixed https://github.com/clojure/clojurescript/commit/deec44aa16a2ce6c8b039dfc286888917b5eaceb





Generated at Tue May 24 08:56:55 CDT 2016 using JIRA 4.4#649-r158309.