<< Back to previous view

[CLJ-438] case* and code walkers Created: 23/Sep/10  Updated: 13/Apr/12  Resolved: 13/Apr/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Defect Priority: Blocker
Reporter: Assembla Importer Assignee: Unassigned
Resolution: Completed Votes: 1
Labels: None

Attachments: Text File 0001-Fix-error-case-in-eval-of-walk-macroexpand-all-outpu.patch    
Approval: Vetted

 Description   

Clojure 1.2.0-master-SNAPSHOT
user=> (use 'clojure.walk)
nil
user=> (eval (macroexpand-all '(case 1 1 :test)))
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.MapEntry (NO_SOURCE_FILE:2)

user=> (macroexpand-all '(case 1 1 :test))
(let* [G__9 1]
(case* G__9 0 1 1 1
(throw (new java.lang.IllegalArgumentException (clojure.core/str "No matching clause: " G__9)))

{1 [1 :test]}

false))

The existing code walkers convert the embedded [1 :test] into a PersistentVector that the compiler doesn't accept.
(symbol-macrolet [x :test] (case 1 1 x)) fails in the same way.



 Comments   
Comment by Assembla Importer [ 01/Oct/10 10:47 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/438

Comment by Colin Jones [ 01/Jan/11 4:13 PM ]

A post-order traversal for macroexpand-all seems more reliable here than pre-order, and does fix the issue.

The attached patch adds tests around this and updates macroexpand-all to use postwalk rather than prewalk.

Comment by Alexander Taggart [ 28/Feb/11 1:51 PM ]

This has been fixed in the patch on CLJ-426.

The CaseExpr parser now just treats the map value as a tuple by calling RT.first/second, rather than casting it to a MapEntry.

Comment by Colin Jones [ 10/Oct/11 9:28 AM ]

Confirming Alex's fix - this ticket can just get closed, I think.

Generated at Thu Jul 31 08:38:26 CDT 2014 using JIRA 4.4#649-r158309.