You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Malformed input either throws an exception that says nothing about the input, or, worse, is silently read as something else. Tested against v0.1.2:
Silently accepted (a wrong answer with no error):
Input
Read as
{1,2
{1}
{1,2}junk
{1,2}jun}
{1,(2))}
{1,(2),)}
Thrown, but with the wrong type or no useful message:
Case
Exception
""
IndexOutOfRangeException
{(1,2},3)
bare System.Exception: "Braces not matched"
an unmatched closing brace
InvalidOperationException from Stack.Pop ("Stack empty")
shape mismatch
InvalidOperationException: "Cannot enumerate over a value", "Cannot index into a set" (stack traces in ReduxISU/Redux#577)
failed subset constraint
message literally says PLACEHOLDER: "Constraint S subset PLACEHOLDER failed because x was not a subset of PLACEHOLDER"
Wanted
Reject malformed input. Unbalanced braces, trailing characters and empty input are errors, never a best guess.
One error type. Throw a dedicated parse exception for every bad-input case, including shape mismatches and failed constraints. Never System.Exception, InvalidOperationException or IndexOutOfRangeException.
Say what's wrong. Include the position, what was expected and what was found, e.g. expected , or } at position 14, found x. Name the set in constraint failures instead of PLACEHOLDER.
Redux context
Redux passes the message straight into the 400's detail.
A gap on the definition side, found by the coverage tests in #39: parse() accepts malformed definition strings. {N | N is set (missing brace), {N | N is set#} and {N | N is set}} are printed to the console by ANTLR's default error listener and then parsed as best it can, which is the "best guess" this issue rules out. Definition (#24) already rejects the same strings with a FormatException and the position.
Fixing this before 0.2.0: StringParser will reject a malformed definition the same way Definition does. ConstraintGapTests.cs has the skipped test to un-skip.
Activity
Trosper3 commentedon Oct 16, 2026
A gap on the definition side, found by the coverage tests in #39:
parse()accepts malformed definition strings.{N | N is set(missing brace),{N | N is set#}and{N | N is set}}are printed to the console by ANTLR's default error listener and then parsed as best it can, which is the "best guess" this issue rules out.Definition(#24) already rejects the same strings with aFormatExceptionand the position.Fixing this before 0.2.0:
StringParserwill reject a malformed definition the same wayDefinitiondoes.ConstraintGapTests.cshas the skipped test to un-skip.