Skip to content

Inhibitor arc is throwing exception #20

@m-h-b-tu

Description

@m-h-b-tu

Unfortunately commit 13f8c40 part of d79ddb0 introduced a bug to class Inhibitor.

In case where a place is unmarked the example Inhibitor(Variable("x")).check(Substitution(x=1), MultiSet([1, 2, 3])) becomes Inhibitor(Variable("x")).check(Substitution(), MultiSet([])) and class Variable throws an exception inside its method bind because the parameter binding does not include self.name.

This might be a quick fix inspired by the modes method:

def check (self, binding, tokens) :
    """Check whether the label allows to fire with tokens

    >>> Inhibitor(Value(1)).check(Substitution(), MultiSet([1, 2, 3]))
    False
    >>> Inhibitor(Value(4)).check(Substitution(), MultiSet([1, 2, 3]))
    True
    >>> Inhibitor(Variable("x")).check(Substitution(x=1), MultiSet([1, 2, 3]))
    False
    >>> Inhibitor(Variable("x")).check(Substitution(x=4), MultiSet([1, 2, 3]))
    True
    """
    try :
        checks = self._annotation.check(binding, tokens)
    except DomainError :
        checks = False
    return (not checks
            and self._condition(binding))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions