Clojure

Evaling #{do ...} or [do ...] is treated as the do special form

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Completed
  • Affects Version/s: Release 1.5
  • Fix Version/s: Release 1.6
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

Problem: Evaluating a persistent collection for which the function first returns the symbol do leads to that collection being treated as the do special form, even though it may be a vector or even a set. IMHO, the expected result would be to report that do cannot be resolved.

[do 1 2]
;=> 2

#{"hello" "goodbye" do}
;=> "hello"
; Wat?

Cause: The check for do is checking for IPersistentCollection instead of ISeq.

Solution: Change the cast (occurs in two places) for the do form check from IPersistentCollection to ISeq:

if(form instanceof IPersistentCollection && Util.equals(RT.first(form), DO))

to

if(form instanceof ISeq && Util.equals(RT.first(form), DO))

Current patch: CLJ-1184-p4.patch

Screened by: Alex Miller

  1. CLJ-1184-p1.patch
    26/May/13 2:13 PM
    2 kB
    Gary Fredericks
  2. CLJ-1184-p2.patch
    02/Jul/13 9:52 PM
    3 kB
    Gary Fredericks
  3. CLJ-1184-p3.patch
    23/Jul/13 10:49 PM
    3 kB
    Alex Miller
  4. CLJ-1184-p4.patch
    14/Aug/13 9:23 PM
    3 kB
    Gary Fredericks

Activity

Stuart Halloway made changes -
Field Original Value New Value
Approval Triaged [ 10120 ]
Rich Hickey made changes -
Approval Triaged [ 10120 ] Vetted [ 10003 ]
Rich Hickey made changes -
Fix Version/s Release 1.6 [ 10157 ]
Gary Fredericks made changes -
Attachment CLJ-1184-p1.patch [ 12015 ]
Andy Fingerhut made changes -
Patch Code and Test [ 10002 ]
Alex Miller made changes -
Approval Vetted [ 10003 ] Incomplete [ 10006 ]
Gary Fredericks made changes -
Attachment CLJ-1184-p2.patch [ 12057 ]
Andy Fingerhut made changes -
Approval Incomplete [ 10006 ] Vetted [ 10003 ]
Alex Miller made changes -
Attachment CLJ-1184-p3.patch [ 12071 ]
Alex Miller made changes -
Approval Vetted [ 10003 ] Screened [ 10004 ]
Description Evaluating a persistent collection for which the function 'first' returns the symbol 'do' leads to that collection being treated as the do special form, even though it may be a vector or even a set. IMHO, the expected result would be to report that 'do' cannot be resolved. For the cause, see the if condition on line 6604 of Compiler.java in clojure-1.5.1.

E.g.:
[do 1 2]
;=> 2

#{"hello" "goodbye" do}
;=> "hello"
; Wat?
*Problem:* Evaluating a persistent collection for which the function 'first' returns the symbol 'do' leads to that collection being treated as the do special form, even though it may be a vector or even a set. IMHO, the expected result would be to report that 'do' cannot be resolved.

{code}
[do 1 2]
;=> 2

#{"hello" "goodbye" do}
;=> "hello"
; Wat?
{code}

*Solution:* Change the cast (occurs in two places) for the DO form check from IPersistentCollection to ISeq:

{code}if(form instanceof IPersistentCollection && Util.equals(RT.first(form), DO)){code}

to

{code}if(form instanceof ISeq && Util.equals(RT.first(form), DO)){code}

*Current patch:* CLJ-1184-p3.patch

Gary Fredericks made changes -
Attachment CLJ-1184-p4.patch [ 12194 ]
Andy Fingerhut made changes -
Description *Problem:* Evaluating a persistent collection for which the function 'first' returns the symbol 'do' leads to that collection being treated as the do special form, even though it may be a vector or even a set. IMHO, the expected result would be to report that 'do' cannot be resolved.

{code}
[do 1 2]
;=> 2

#{"hello" "goodbye" do}
;=> "hello"
; Wat?
{code}

*Solution:* Change the cast (occurs in two places) for the DO form check from IPersistentCollection to ISeq:

{code}if(form instanceof IPersistentCollection && Util.equals(RT.first(form), DO)){code}

to

{code}if(form instanceof ISeq && Util.equals(RT.first(form), DO)){code}

*Current patch:* CLJ-1184-p3.patch

*Problem:* Evaluating a persistent collection for which the function 'first' returns the symbol 'do' leads to that collection being treated as the do special form, even though it may be a vector or even a set. IMHO, the expected result would be to report that 'do' cannot be resolved.

{code}
[do 1 2]
;=> 2

#{"hello" "goodbye" do}
;=> "hello"
; Wat?
{code}

*Solution:* Change the cast (occurs in two places) for the DO form check from IPersistentCollection to ISeq:

{code}if(form instanceof IPersistentCollection && Util.equals(RT.first(form), DO)){code}

to

{code}if(form instanceof ISeq && Util.equals(RT.first(form), DO)){code}

*Current patch:* CLJ-1184-p4.patch

Alex Miller made changes -
Description *Problem:* Evaluating a persistent collection for which the function 'first' returns the symbol 'do' leads to that collection being treated as the do special form, even though it may be a vector or even a set. IMHO, the expected result would be to report that 'do' cannot be resolved.

{code}
[do 1 2]
;=> 2

#{"hello" "goodbye" do}
;=> "hello"
; Wat?
{code}

*Solution:* Change the cast (occurs in two places) for the DO form check from IPersistentCollection to ISeq:

{code}if(form instanceof IPersistentCollection && Util.equals(RT.first(form), DO)){code}

to

{code}if(form instanceof ISeq && Util.equals(RT.first(form), DO)){code}

*Current patch:* CLJ-1184-p4.patch

*Problem:* Evaluating a persistent collection for which the function {{first}} returns the symbol {{do}} leads to that collection being treated as the do special form, even though it may be a vector or even a set. IMHO, the expected result would be to report that {{do}} cannot be resolved.

{code}
[do 1 2]
;=> 2

#{"hello" "goodbye" do}
;=> "hello"
; Wat?
{code}

*Cause:* The check for {{do}} is checking for IPersistentCollection instead of ISeq.

*Solution:* Change the cast (occurs in two places) for the {{do}} form check from IPersistentCollection to ISeq:

{code}if(form instanceof IPersistentCollection && Util.equals(RT.first(form), DO)){code}

to

{code}if(form instanceof ISeq && Util.equals(RT.first(form), DO)){code}

*Current patch:* CLJ-1184-p4.patch

*Screened by:* Alex Miller

Alex Miller made changes -
Labels Compiler bug Compiler
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: