Thanks to visit codestin.com
Credit goes to github.com

Skip to content

set-type should be able to be used in constraint block to constrain random variable's range #20

@LeeKaiXuan

Description

@LeeKaiXuan

Description

In constraint block, a set-type should be able to be used to constrain a random variable's range.

Scenario Code

component pss_top {
    action root_a {
        activity {
            do constraintBySet with { value in [1]; };
        }
    }

    action constraintBySet {
        rand int value;
        set<int> foo = {1, 3, 5, 7};

        constraint { value in foo; }
        exec body ASM = """constraintBySet: {{value}}""";
    }
}

Expected Output or Behaviour

constraintBySet: 1

Error Message from PSSGen or JAVA

Exception in thread "main" java.lang.ClassCastException: class PSSSetVal cannot be cast to class PSSListVal (PSSSetVal and PSSListVal are in unnamed module of loader 'app')
        at PSSInExpression.deduceDomain(PSSInExpression.java:17)
        at PSSExpressionConstraint.deduceDomain(PSSExpressionConstraint.java:11)
        at PSSSolver.reduceDomain(PSSSolver.java:49)
        at PSSSolver.solve(PSSSolver.java:80)
        at PSSActionModel.traverse(PSSActionModel.java:154)
        at PSSTraversalList.traverse(PSSTraversalList.java:80)
        at PSSActionInst.traverseSubAction(PSSActionInst.java:35)
        at PSSActionModel.traverse(PSSActionModel.java:167)
        at PSSGenMain.traverseRootAction(PSSGenMain.java:77)
        at PSSGenMain.main(PSSGenMain.java:15)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions