Clojure-Contrib

clojure.contrib.core/-?> (and perhaps others?) have a quoting bug

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    1.2 and 1.3
  • Patch:
    Code

Description

See:

https://groups.google.com/group/clojure/browse_frm/thread/cc88ca26352bc604?hl=en#

When called via a namespace-qualified symbol and given three or more arguments, -?> gives the error:

user=> (clojure.contrib.core/-?> 1 inc inc)
CompilerException java.lang.Exception: Unable to resolve symbol: -?>
in this context, compiling:(NO_SOURCE_PATH:3)

  1. fix-CONTRIB-102.diff
    08/Dec/10 2:11 AM
    2 kB
    Laurent Petit
  2. patch.diff
    09/Jan/11 4:23 AM
    1 kB
    Alan Malloy

Activity

Hide
Alan Malloy added a comment -

Root cause is in clojure.contrib.core/defnilsafe, so similar functions like .?. will have the same problem. I futzed around for a while to try and figure it out, but defnilsafe is a little too meta for me. The problem is, predictably enough once you've glanced at the code, with ~'~nil-safe-name.

The general solution ought to look like
(let [qname (symbol (name (ns-name *ns*)) (str nil-safe-name))]
`(existing body...
(more stuff using ~qname instead of ~'~nil-safe-name...)))

But I couldn't make it quite work.

Show
Alan Malloy added a comment - Root cause is in clojure.contrib.core/defnilsafe, so similar functions like .?. will have the same problem. I futzed around for a while to try and figure it out, but defnilsafe is a little too meta for me. The problem is, predictably enough once you've glanced at the code, with ~'~nil-safe-name. The general solution ought to look like (let [qname (symbol (name (ns-name *ns*)) (str nil-safe-name))] `(existing body... (more stuff using ~qname instead of ~'~nil-safe-name...))) But I couldn't make it quite work.
Laurent Petit made changes -
Field Original Value New Value
Assignee Laurent Petit [ laurentpetit ]
Laurent Petit made changes -
Attachment fix-CONTRIB-102.diff [ 10047 ]
Hide
Laurent Petit added a comment -

Patch added.

Simple patch where I specifically use fully qualified names when calling defnilsafe.

Show
Laurent Petit added a comment - Patch added. Simple patch where I specifically use fully qualified names when calling defnilsafe.
Laurent Petit made changes -
Status Open [ 1 ] In Progress [ 3 ]
Laurent Petit made changes -
Approval Test
Patch Code
Laurent Petit made changes -
Status In Progress [ 3 ] Open [ 1 ]
Hide
Alan Malloy added a comment -

What about this patch instead? It makes sure to resolve the symbols supplied to defnilsafe while still within the c.c.core namespace.

I also made the arglists a bit less ugly.

Show
Alan Malloy added a comment - What about this patch instead? It makes sure to resolve the symbols supplied to defnilsafe while still within the c.c.core namespace. I also made the arglists a bit less ugly.
Alan Malloy made changes -
Attachment patch.diff [ 10075 ]
Alex Miller made changes -
Approval Test [ 10013 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: