Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Bump to latest riddley (0.1.7) #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trptcolin
Copy link

This is a fix for #3 - potentially the wrong one, but bumping riddley can't hurt, right?

The actual issue: letfn isn't having its locals registered as part of the letfn* transformation, so its bindings aren't visible to the analyzer inside nested let expressions. So swallowing analysis errors as riddley 0.1.7 gets this use case working, but I'm assuming the right fix is to register locals for letfn.

In digging into a potential locals-registering solution, my quicky & easy (but dirty, poking at internals) idea:

diff --git a/src/proteus.clj b/src/proteus.clj
index 7eadb2e..d73b710 100644
--- a/src/proteus.clj
+++ b/src/proteus.clj
@@ -50,7 +50,9 @@
             vs' (map #(gensym (name %)) vs)]
         `(let [~@(interleave vs' vs)
                ~@(interleave vs (map read-form vs))]
-           (~'letfn* ~bindings
+           (~'letfn* ~(#'riddley.walk/let-bindings
+                        transform-let-mutable-form
+                        bindings)
              (let [~@(interleave vs vs')]
                ~(transform-let-mutable-form `(do ~@body))))))

didn't work, got a java.lang.UnsupportedOperationException: Can't type hint a primitive local.

Surprisingly (to me), inlining the implementation of let-bindings seemed to do the trick:

diff --git a/src/proteus.clj b/src/proteus.clj
index 7eadb2e..39b1c98 100644
--- a/src/proteus.clj
+++ b/src/proteus.clj
@@ -50,7 +50,14 @@
             vs' (map #(gensym (name %)) vs)]
         `(let [~@(interleave vs' vs)
                ~@(interleave vs (map read-form vs))]
-           (~'letfn* ~bindings
+           (~'letfn* ~(->> bindings
+                           (partition-all 2)
+                           (mapcat
+                             (fn [[k v]]
+                               (let [[k v] [k (transform-let-mutable-form v)]]
+                                 (riddley.compiler/register-local k v))
+                               [k v]))
+                           vec)
              (let [~@(interleave vs vs')]
                ~(transform-let-mutable-form `(do ~@body))))))

But that seemed pretty awful, and might not even be necessary - I don't have a full mental model of the consequences of analysis errors in this context.

letfn isn't having its locals registered as part of the letfn*
transformation, so its bindings weren't visible to the analyzer inside
nested let expressions. So swallowing analysis errors as riddley
0.1.7 gets this use case working, but the right fix is probably to
register locals for letfn.

refs ztellman#3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant