Clojure

1.7.0-alpha3 breakage due to symbol conflicts

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: Release 1.7
  • Fix Version/s: Release 1.7
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code
  • Approval:
    Ok

Description

I've been trying to build core.matrix with 1.7.0-alpha3 and I get a failures due to symbol conflicts with clojure.core (specifically the new update function).

java.lang.IllegalStateException: update already refers to: #'clojure.core.matrix.utils/update in namespace: clojure.core.matrix.impl.ndarray-magic
	at clojure.lang.Namespace.warnOrFailOnReplace(Namespace.java:88)
	at clojure.lang.Namespace.reference(Namespace.java:110)
	at clojure.lang.Namespace.refer(Namespace.java:168)
	at clojure.core$refer.doInvoke(core.clj:4071)
	at clojure.lang.RestFn.invoke(RestFn.java:439)
	at clojure.core.matrix.impl.ndarray_magic$eval9762$loading__5295__auto____9763.invoke(ndarray_magic.clj:1)
	at clojure.core.matrix.impl.ndarray_magic$eval9762.invoke(ndarray_magic.clj:1)

Simpler case to reproduce:

(ns foo)
(def inc dec) ;; gets a warning 
(ns bar (:require [foo :refer :all])) ;; gets another warning
(ns bar (:require [foo :refer :all])) ;; causes the exception (effectively a ns reload)

Cause: In the case of a load, foo/inc is replacing clojure.core/inc and that causes the expected warning. In the case of a reload, clojure.core/inc is replacing foo/inc - this case is not currently handled and falls into the error case.

Approach: In the case of clojure.core/inc replacing foo/inc (should only happen during a reload), ignore and issue neither warning or error.

Patch: 0001-CLJ-1578-don-t-throw-when-a-core-Var-replaces-anothe.patch

Screened by: Alex Miller

Activity

Mike Anderson made changes -
Field Original Value New Value
Description I've been trying to build core.matrix with 1.7.0-alpha3 and I get a combinations of warnings and failures due to symbol conflicts with clojure.core

Warnings:
WARNING: update already refers to: #'clojure.core/update in namespace: clojure.core.matrix, being replaced by: #'clojure.core.matrix.utils/update

Errors:
java.lang.IllegalStateException: update already refers to: #'clojure.core.matrix.utils/update in namespace: clojure.core.matrix.impl.ndarray-magic
at clojure.lang.Namespace.warnOrFailOnReplace(Namespace.java:88)
at clojure.lang.Namespace.reference(Namespace.java:110)
at clojure.lang.Namespace.refer(Namespace.java:168)
at clojure.core$refer.doInvoke(core.clj:4071)
at clojure.lang.RestFn.invoke(RestFn.java:439)
at clojure.core.matrix.impl.ndarray_magic$eval9762$loading__5295__auto____9763.invoke(ndarray_magic.clj:1)
at clojure.core.matrix.impl.ndarray_magic$eval9762.invoke(ndarray_magic.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6767)
at clojure.lang.Compiler.eval(Compiler.java:6756)
at clojure.lang.Compiler.load(Compiler.java:7194)

I believe the correct behaviour would be:
- allow namespaces to override names in clojure.core (at their own risk, of course).
- warnings should be off by default, otherwise this will create unreasonable false warnings in correct code.
- never throw exceptions (I guess it could be a configurable setting if people really want it - I don't see the value though)

I reported it before as CLJ-1401 (when it was just an annoyance) but now this is breaking backwards compatibility with real code.
I've been trying to build core.matrix with 1.7.0-alpha3 and I get a combinations of warnings and failures due to symbol conflicts with clojure.core

Warnings:
WARNING: update already refers to: #'clojure.core/update in namespace: clojure.core.matrix, being replaced by: #'clojure.core.matrix.utils/update

Errors:
java.lang.IllegalStateException: update already refers to: #'clojure.core.matrix.utils/update in namespace: clojure.core.matrix.impl.ndarray-magic
at clojure.lang.Namespace.warnOrFailOnReplace(Namespace.java:88)
at clojure.lang.Namespace.reference(Namespace.java:110)
at clojure.lang.Namespace.refer(Namespace.java:168)
at clojure.core$refer.doInvoke(core.clj:4071)
at clojure.lang.RestFn.invoke(RestFn.java:439)
at clojure.core.matrix.impl.ndarray_magic$eval9762$loading__5295__auto____9763.invoke(ndarray_magic.clj:1)
at clojure.core.matrix.impl.ndarray_magic$eval9762.invoke(ndarray_magic.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6767)
at clojure.lang.Compiler.eval(Compiler.java:6756)
at clojure.lang.Compiler.load(Compiler.java:7194)

I believe the correct behaviour would be:
- allow namespaces to override names in clojure.core (at their own risk, of course).
- warnings should be off by default, otherwise this will create unreasonable false warnings in correct code.
- never throw exceptions (I guess it could be a configurable setting if people really want it - I don't see the value though)

I reported a related issue before as CLJ-1401 (when it was just an annoyance) but now this is breaking backwards compatibility with real code.
Alex Miller made changes -
Fix Version/s Release 1.7 [ 10250 ]
Approval Vetted [ 10003 ]
Nicola Mometto made changes -
Nicola Mometto made changes -
Patch Code [ 10001 ]
Alex Miller made changes -
Description I've been trying to build core.matrix with 1.7.0-alpha3 and I get a combinations of warnings and failures due to symbol conflicts with clojure.core

Warnings:
WARNING: update already refers to: #'clojure.core/update in namespace: clojure.core.matrix, being replaced by: #'clojure.core.matrix.utils/update

Errors:
java.lang.IllegalStateException: update already refers to: #'clojure.core.matrix.utils/update in namespace: clojure.core.matrix.impl.ndarray-magic
at clojure.lang.Namespace.warnOrFailOnReplace(Namespace.java:88)
at clojure.lang.Namespace.reference(Namespace.java:110)
at clojure.lang.Namespace.refer(Namespace.java:168)
at clojure.core$refer.doInvoke(core.clj:4071)
at clojure.lang.RestFn.invoke(RestFn.java:439)
at clojure.core.matrix.impl.ndarray_magic$eval9762$loading__5295__auto____9763.invoke(ndarray_magic.clj:1)
at clojure.core.matrix.impl.ndarray_magic$eval9762.invoke(ndarray_magic.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6767)
at clojure.lang.Compiler.eval(Compiler.java:6756)
at clojure.lang.Compiler.load(Compiler.java:7194)

I believe the correct behaviour would be:
- allow namespaces to override names in clojure.core (at their own risk, of course).
- warnings should be off by default, otherwise this will create unreasonable false warnings in correct code.
- never throw exceptions (I guess it could be a configurable setting if people really want it - I don't see the value though)

I reported a related issue before as CLJ-1401 (when it was just an annoyance) but now this is breaking backwards compatibility with real code.
I've been trying to build core.matrix with 1.7.0-alpha3 and I get a failures due to symbol conflicts with clojure.core (specifically the new {{update}} function).

{code}
java.lang.IllegalStateException: update already refers to: #'clojure.core.matrix.utils/update in namespace: clojure.core.matrix.impl.ndarray-magic
at clojure.lang.Namespace.warnOrFailOnReplace(Namespace.java:88)
at clojure.lang.Namespace.reference(Namespace.java:110)
at clojure.lang.Namespace.refer(Namespace.java:168)
at clojure.core$refer.doInvoke(core.clj:4071)
at clojure.lang.RestFn.invoke(RestFn.java:439)
at clojure.core.matrix.impl.ndarray_magic$eval9762$loading__5295__auto____9763.invoke(ndarray_magic.clj:1)
at clojure.core.matrix.impl.ndarray_magic$eval9762.invoke(ndarray_magic.clj:1)
{code}

Simpler case to reproduce:
{code}
(ns foo)
(def inc dec) ;; gets a warning
(ns bar (:require [foo :refer :all])) ;; gets another warning
(ns bar (:require [foo :refer :all])) ;; causes the exception (effectively a ns reload)
{code}

*Cause:* In the case of a load, foo/inc is replacing clojure.core/inc and that causes the expected warning. In the case of a reload, clojure.core/inc is replacing foo/inc - this case is not currently handled and falls into the error case.

*Approach:* In the case of clojure.core/inc replacing foo/inc (should only happen during a reload), ignore and issue neither warning or error.

*Patch:* 0001-CLJ-1578-don-t-throw-when-a-core-Var-replaces-anothe.patch

*Screened by:* Alex Miller
Approval Vetted [ 10003 ] Screened [ 10004 ]
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Status Open [ 1 ] Closed [ 6 ]
Resolution Completed [ 1 ]
Mike Anderson made changes -
Resolution Completed [ 1 ]
Status Closed [ 6 ] Reopened [ 4 ]
Nicola Mometto made changes -
Status Reopened [ 4 ] Closed [ 6 ]
Resolution Completed [ 1 ]

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: