<< Back to previous view

[CLJS-849] Incorrect transients behavior (dissoc! deletes too much) Created: 02/Sep/14  Updated: 04/Sep/14  Resolved: 04/Sep/14

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Eldar Gabdullin Assignee: Michał Marczyk
Resolution: Completed Votes: 0
Labels: maps, transient

Attachments: Text File 0001-CLJS-849-fix-iteration-bound-in-pack-array-node.patch    

 Description   

The snippet below reproduces the problem

(defn bug [seq]
  (let [m (transient (zipmap seq (repeat 1)))]
    (loop [m m
           [x & rest] seq]
      (when x
        (if (contains? m x)
          (recur (dissoc! m x) rest)
          (throw (js/Error. "What's going on?")))))))

(bug [44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24]]


 Comments   
Comment by Eldar Gabdullin [ 02/Sep/14 12:46 PM ]

Ah, transient lookup is not supported in Clojure. Why it is allowed in ClojureScript, then?

Comment by Nicola Mometto [ 02/Sep/14 12:49 PM ]

The fact that contains? doesn't work in clojure is a bug, see http://dev.clojure.org/jira/browse/CLJ-700

Comment by Eldar Gabdullin [ 02/Sep/14 12:51 PM ]

Right, already spotted that.

Comment by Michał Marczyk [ 04/Sep/14 5:02 AM ]

Wow, this is a pretty serious bug – thanks!

It is caused by an incorrect iteration bound in pack-array-node. The attached patch fixes it.

Comment by Michał Marczyk [ 04/Sep/14 5:09 AM ]

Oops, forgot the test. Attaching the same fix + test case.

Comment by Michał Marczyk [ 04/Sep/14 5:31 AM ]

A final tweak.

Comment by David Nolen [ 04/Sep/14 7:31 AM ]

fixed https://github.com/clojure/clojurescript/commit/699b7487805c786b2eebe122ca3f09d7a5205c9e

Comment by Eldar Gabdullin [ 04/Sep/14 11:48 AM ]

Thank you.





[CLJS-799] Having a namespace end with ".cljs" produces wrong source map Created: 16/Apr/14  Updated: 16/Apr/14

Status: Open
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Sven Richter Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: maps, namespace, source
Environment:

Windows 7
JDK 1.7
CLJS version: 0.0-2138 and 0.0-2156 (probably hits other versions too, but I only tested these two)



 Description   

When an clojurescript namespaces ends with ".cljs" I cannot see the source file in google chrome.
Repro steps:

1. Create a new luminus project with: lein new luminus cljsbug +cljs +http-kit
2. Change the project.clj cljsbuild -> compiler setting to:
:compiler
{:output-to "resources/public/js/site.js"
:output-dir "resources/public/js/out"
:optimizations :none
:source-map true
}
3. Change cljsexample.html file to:
<script type="text/javascript" src="js/out/goog/base.js"></script>
<script type="text/javascript" src="servlet-context/js/site.js"></script>
<script type="text/javascript">goog.require("cljsbug.main");</script>

4. Now start the server with "lein run -dev" and "lein cljsbuild auto"
5. Open localhost:3000/cljsexample
6. Check for the source file in google chrome

It should be there now and correct.
Now to reproduce the problem do this:

7. Change the namespace of the main.cljs file to: ns cljsbug.main.cljs
8. Change the cljsexample.html goog.require line to: <script type="text/javascript">goog.require("cljsbug.main.cljs");</script>

9. Restart the cljsbuild with: lein do cljsbuild clean, cljsbuild auto
10. Reload the /cljsexample page in google chrome and the source mapping wont be there anymore.



 Comments   
Comment by Sven Richter [ 16/Apr/14 2:38 PM ]

Just to clear things up. Steps 1 to 6 are not needed to reproduce the problem. It is sufficient to go through steps 7 to 10 on any project that uses a similar cljsbuild setting.
It is important that optimizations are set to :none.

Short repro version.

1. Have cljs project with the following settings:
:compiler
{:output-to "resources/public/js/site.js"
:output-dir "resources/public/js/out"
:optimizations :none
:source-map true
}

2. Change any cljs file namespace and add ".cljs" to the namespace.
3. Have the new namespace required in the html file by google like this: goog.require("cljsbug.main.cljs")

4. Open a page in the browser and see that the source maps are missing.





[CLJS-623] Keyword dosen't work as a function of map Created: 16/Oct/13  Updated: 20/Oct/13  Resolved: 20/Oct/13

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Andrzej Fricze Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: keywords, lookup, maps
Environment:

Compiling with [org.clojure/clojurescript "0.0-1934"]. Using Light Table to develop.



 Description   

String version access to map

("a" {"a" "ala" :b "bala"}) ;; returns "ala"

unfortunately, the keyword version

(:b {"a" "ala" :b "bala"}) ;; returns nil

I've tried using keyword as function of map, and map as a function with keyword arg. Even using vector as a key in a map works properly, only if map is called with key arg, but still, it works

({[1 2] "ala" :c "bala"} [1 2]) ;; returns "ala"

({"a" "ala" :b "bala"} :b) ;; still nil



 Comments   
Comment by Travis Thieman [ 17/Oct/13 10:39 AM ]

Using the latest version of ClojureScript and script/repl and script/repljs, I observe the following:

1. Your first string example doesn't work in either Clojure or ClojureScript. This is expected behavior as far as I know; you can't access maps using a string the same way you can with a keyword.

2. Your second example, (:b {"a" "ala" :b "bala"}) works fine for me in both Clojure and ClojureScript REPLs.

3. Third example works fine.

4. Fourth example returns "bala" for me in both REPLs.

If you are actually seeing this behavior, my guess would be that the issue is with Light Table. Can you reproduce this in a REPL outside of Light Table?

Comment by Andrzej Fricze [ 18/Oct/13 4:08 PM ]

I've checked in ClojureScript REPL and it works, indeed. You're right, it must be Light Table case. Very sorry for interrupting then.





Generated at Sat Nov 01 01:51:25 CDT 2014 using JIRA 4.4#649-r158309.