Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection functions are not accessing stacked values #32

Open
Locke opened this issue Feb 10, 2019 · 0 comments
Open

Collection functions are not accessing stacked values #32

Locke opened this issue Feb 10, 2019 · 0 comments

Comments

@Locke
Copy link
Contributor

Locke commented Feb 10, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant