Skip to content

Fix parser bugs in check_quants, -t flag, and related functions - #70

Merged
kovzol merged 2 commits into
kovzol:masterfrom
khush3e:master
Aug 20, 2026
Merged

Fix parser bugs in check_quants, -t flag, and related functions#70
kovzol merged 2 commits into
kovzol:masterfrom
khush3e:master

Conversation

@khush3e

@khush3e khush3e commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Problem

  • Sentences with two quantifiers in disjoint scopes (e.g. ∀x P(x) ∨ ∀x Q(x)) were incorrectly rejected with "Unrecognised or invalid quantifier symbol" because check_quants compared bound variables across the entire flat string with no notion of scope. Additionally, aris -t 'BAD TEXT' would exit 0 and print "Correct!" even for invalid input.

Changes

  • process.c — check_quants: Replaced scope-blind O(n²) duplicate check with a scope-aware walk; uses parse_parens to bound the search to each quantifier's governing group. Disjoint scopes may now reuse variable names; nested re-binding (∀x∀x, ∀x(P∧∀x Q)) is still rejected.
  • aris.c — -t flag: Changed c_ret == -1 to c_ret != 1 so parse failures (return 0) correctly exit with EXIT_FAILURE.
  • process.c — check_sides_quant: Fixed init_pos >= 0 guard (always true for unsigned int) to init_pos >= (unsigned)CL, preventing an OOB read before the string when the quantifier is at position 0.
  • goal.c — goal_check_line: Distinguishes AEC_MEM (-1) from parse errors (-2..-9); invalid goal text now marks the goal as unmet instead of propagating a fake memory error.
  • process.c — check_conns: Added explicit j >= 1 guard before chk_str[j-1] access in the NOT-placement check.
  • process.c — reverse_parse_parens: Removed a '\0' write one byte past the calloc'd buffer.

@kovzol
kovzol merged commit 0a9453b into kovzol:master Aug 20, 2026
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants