Skip to content

is int and is set constraints don't check their type #10

Open

Description

@Trosper3

Problem

The is int and is set constraints don't check what they say. In ConstraintDescriptor.check:

  • is int only checks that the field is a single value, not that it's an integer.
  • is set only checks that the field isn't a list. A plain value counts as unordered, so it passes.

Tested against v0.1.2:

Grammar Input Result Expected
{N | N is int} abc accepted rejected
{W | W is set} balanced accepted rejected

S subset int does check for integers correctly (it uses int.TryParse), so is int can reuse that check.

Fix

  • is int: require a value that parses as an integer.
  • is set: require an unordered collection (not a value).
  • is list: likewise require an ordered collection. Check it, since it has the same structure.
  • Throw the dedicated parse exception from Clear parse errors #4 on failure.

Redux context

Redux grammars rely on these, e.g. w is int for edge weights in MAXCUT and N is set in Partition, so bad input can get past the grammar today. Related to the type checks in #6.

Activity

  1. added this to the 0.2.0 milestone on Oct 13, 2026
  2. Trosper3 commented on Oct 20, 2026

    @Trosper3
    ContributorAuthor

    Reopened: this was closed automatically when #11 merged, because #11's stack table said "closes #10" while describing the other PRs. The fix for this issue is still open in #15, which now closes only its own issue. #9 stays closed; #11 fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions