Code allowed to re-define referred var

Description

If you refer a var from another namespace, then you can def a new value for that var, and the def will mutate the other namespace, and other things will go wrong as illustrated in the example below.

FWIW, Clojure disallows this, and refuses to allow you to evaluate a def involving a referred var, and emits an error diagnostic like:

Here is a complete example illustrating the issues:

Given:

then do this in a REPL:

Environment

None

Attachments

3

Activity

Show:

Mike Fikes July 16, 2018 at 4:28 PM

CLJS-1558-3.patch rebaselines

Mike Fikes July 2, 2018 at 6:14 PM

CLJS-1558-2.patch rebaselines

Mike Fikes November 27, 2017 at 8:05 PM

Here is an example showing that it is (as was before), OK to define a Var that shadows a core Var:

Mike Fikes November 27, 2017 at 8:00 PM

The attached patch essentially turns the warning into an error for non-core names, throwing an exception that matches Clojure's.

Example:

Details

Assignee

Reporter

Patch

Code and Test

Affects versions

Priority

Created January 31, 2016 at 11:42 PM
Updated July 16, 2018 at 4:28 PM