Bystroushaak / tinySelf

Self-like language implemented in the RPython language toolkit.
29 stars 3 forks source link

Parent cache is broken #124

Closed Bystroushaak closed 5 years ago

Bystroushaak commented 5 years ago

Following tinySelf code:

(|
    test_while_100 = (| i <- 0. |
        [ i < 1 ] whileTrue: [
            i: i + 1.
            false.
        ].

        "Result of first while cycle: " print.
        i asString printLine.
    ).
    test_another = (| x. brekeke. |
        x: 0.
        "Running second block .." printLine.

        brekeke.

        [ x < 2 ] whileTrue: [
            x: x + 1.
            nil.
        ].

        "This should be 2: " print.
        x asString printLine.
    ).

    test_while = (||
        test_while_100.
        test_another.
    ).
|) test_while.

(brekeke is there just to provide convenient breakpoint in pycharm)

should print:

Result of first while cycle: 1
Running second block ..
This should be 2: 2

but prints:

Result of first while cycle: 1
Running second block ..
This should be 2: 0

instead. Investigation shows that parent cache returns invalid object (previous block) to value request. When the cache is disabled:

    def parent_lookup(self, slot_name):
...
        # result = self._cached_lookup(slot_name)
        # if result is not None:
        #     return result

everything works as expected.

Details: