Clojure

case* and code walkers

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Backlog
  • Component/s: None
  • Labels:
    None
  • 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.

Activity

Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - Converted from http://www.assembla.com/spaces/clojure/tickets/438
Hide
Colin Jones added a comment -

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.

Show
Colin Jones added a comment - 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.
Hide
Alexander Taggart added a comment - - edited

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.

Show
Alexander Taggart added a comment - - edited 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.
Hide
Colin Jones added a comment -

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

Show
Colin Jones added a comment - Confirming Alex's fix - this ticket can just get closed, I think.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: