Skip to content

Collection functions are not accessing stacked values #32

@Locke

Description

@Locke

With P seq Q the rule Q should behave like all updates from P were applied (Definition 4.1.1. on page 161 of the ASM Book).

Therefore I expect these two rules to have the same output:

rule Case1 =
    if myNumbers = undef then {
        myNumbers := {1, 2}
        numberData(1) := "one"
        numberData(2) := "two"
    }
    else
        // "data: {one, two}"
        print "data: " + map(myNumbers, @numberData)
rule Case2 =
    seq {
        myNumbers := {1, 2}
        numberData(1) := "one"
        numberData(2) := "two"
    }
    next
        // "data: {undef}"
        print "data: " + map(myNumbers, @numberData)

While the first case correctly prints "data: {one, two}" (in the second step) the second case prints "data: {undef}" (in the first step). More specifically I created test files for the map, filter and fold functions here: Locke@11b167e

I looked into the implementation a bit and it doesn't seem like a simple bug but more like a design problem of the map, filter and fold functions.

The interpreter correctly resolves both arguments myNumbers and @numberData through interpretExpressions -> frNode.getArguments -> getUnevaluatedNode. But then for example the method MapFunctionElement.getValue just calls getValue on the MapFunction of @numberData and not getValue on the storage - which should correctly load the value from the stack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions