[squeak-dev] [BUG] Compiler Bug: Code generation with cascade and #caseOf: fails

Eliot Miranda eliot.miranda at gmail.com
Sun Jan 19 01:41:23 UTC 2020


Hi Christoph,

On Sat, Jan 18, 2020 at 12:10 PM Thiede, Christoph <
Christoph.Thiede at student.hpi.uni-potsdam.de> wrote:

> *Steps to reproduce:*
>
> Do it:
>
> Object compile: '
>
> foo: anObject
>
> ^ self foo
>
>     flag: #bar;
>
>     caseOf: { [#corge] -> [self grault: anObject] }
>
> '
>
>
> *Error:*
>
> In TempVariableNode >> #isReferencedWithinBlockExtent::
> MessageNotUnderstood: UndefinedObject >> #rangleIncludes:.
>
> anInterval is nil.
>
> In #computeCopiedValues:, blockExtent of the BlockNode {[#corge]} is nil.
>
>
> This may be related to the observation made in
> http://forum.world.st/BUG-Cannot-compile-cascade-sent-to-block-td5108942.html that
> blockExtent can be nil.
>
> Maybe we should handle optimized BlockNodes differently in this method?
>
> Not (yet?) further investigated.
>

I see a contradiction.  The cascaded message "caseOf: { [#corge] -> [self
grault: anObject]" has special = 0, which means it hasn't been optimized.
But both of its blocks are marked as being optimized.  We can't have that
discrepancy.  Ether a cascaded caseOf: is (to be) inlined (special > 0) and
its blocks are optimized, or it is not to be inlined and its blocks are not
to be optimized.

Ah, the bug I believe is this:

ensureCanCascade: encoder
special > 0 ifTrue:
[special := 0.
receiver := originalReceiver.
selector := encoder encodeSelector: originalSelector.
arguments := originalArguments.
receiver isBlockNode ifTrue: [receiver deoptimize].
arguments do:
[:each|
each isBlockNode ifTrue:
[each deoptimize]]]

This assumes that optimized blocks only appear as arguments, not also in
BraceNode elements, as they do in case statements.
Fixed in Compiler-eem.416

_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200118/b86c6b90/attachment.html>


More information about the Squeak-dev mailing list