Summary

spock generates unreachable code

Metadata

Attachments

Description

The spock runtime (both spock-runtime.js and spock-runtime-debug.js) contains unreachable code. Example:

  ____25call_2dwith_2dsaved_2dvalues = t1355;	// set! %call-with-saved-values
 ...
     var t6 = t1358;
     var t1360;
     if(t6 !== false) {
      return k1100(t6);
      t1360 = undefined;
     }
 ...

The assignment t1360 = undefined; is never reached, as there is a return statement immediately before.

Tip to find such cases: search for " = undefined" in spock-runtime.js or spock-runtime-debug.js.

I don't know exactly how this affects code, but the firebug console prints thousands of warnings because of this.

Changes and comments

[2016-10-02 17:59:51 UTC] felix attached spock-dead-assign-undefined.diff (description=#f)

[2016-10-02 18:02:26 UTC] felix wrote:

Can you try the attached Patch? The reason for these assignments is that the compiler does not detect whether conditional branches return. The patch avoids an assignment to variable if the branch has an unspecified result. The variable declared before the conditional (holding the result of either branch) is initialized to undefined anyway, so this should work as before.

There may be more cases of dead assignments, but this patch should eliminate most.

[2016-10-02 19:21:07 UTC] mario wrote:

Thanks, Felix. You patch seems to do the trick.

[2016-10-02 19:32:26 UTC] felix wrote:

Very good, I'll push a new version, together with your fix from #1331

[2016-10-02 19:32:43 UTC] felix changed status from new to closed

[2016-10-02 19:32:43 UTC] felix set resolution to fixed