Use this skill when
- Editing
src/Htcc/Parser/**or parser-facing code inapp/Main.hs. - Review feedback mentions parse acceptance, parse errors,
ATEmpty,manyTill, EOF,Megaparsec, scope restoration, declarations, initializers, or implicit calls. - A malformed C input can hang, parse successfully by mistake, or produce the wrong diagnostic.
Do not use this skill when
- The change is pure codegen/output behavior after parsing has already succeeded.
Investigation steps
- Read the exact parser function and the nearest combinators it composes with.
- Search for zero-width success in recursive or repeated contexts:
M.many,M.manyTill,M.option,ATEmpty,M.eof,M.try. - Identify whether the parser must fail, consume input, or produce
ATEmptyintentionally. - Check existing component tests in
test/Tests/ComponentsTests/Parser/Combinators.hsbefore adding new helpers.
Regression test placement
- Put parser unit regressions in
test/Tests/ComponentsTests/Parser/Combinators.hswhen directparseProgram,parseAssignExpr, or helper assertions can reproduce the bug. - Put CLI parser regressions in subprocess tests only when stderr/exit-code behavior is the relevant contract.
- Prefer adding cases under the existing
Parser.Program.*group matching the construct, such asfunction-call,scalar-initializer, orfunction-pointer-arithmetic. - For call argument lists, trailing commas such as
f(1,)are malformed. For initializer lists, check existing accepted C-like trailing-comma behavior before turning a trailing comma into a rejection. - For initializer EOF regressions, consider both file-scope and local-scope shapes such as
int g =,int g = {1, andint main(){ int x =.
Nontermination safeguards
- Any bug involving EOF, repeated combinators, or
manyTillmust have a timeout-guarded manual QA command, for example:
printf 'int main(){ return f(' | timeout 5s stack exec htcc -- /dev/stdin
- The expected outcome for malformed input is non-zero exit before the timeout, not success.
- Use
timeoutorgtimeout, whichever exists on the host, and report the command used. - Do not fix nontermination by accepting malformed input as
ATEmpty.
Verification
stylish-haskell -i <all changed .hs files, including app/Main.hs when touched> test/Tests/ComponentsTests/Parser/Combinators.hslsp_diagnosticson edited Haskell files when the diagnostics tool is available. If unavailable, state that and substitutestack buildplus the relevant test command.stack test --test-arguments components.- Full
stack testfor parser-wide behavior or when the change affects common expression/statement parsing. stack build.- Manual CLI QA for malformed inputs when user-visible parser behavior or hangs are involved.
Review focus
- Does the fix remove the bad acceptance path without breaking intended empty statements or empty
forsections? - Do the tests cover both minimal malformed shape and comma/trailing-argument shape where applicable?
- Does the parser fail with a parse error rather than looping or producing a misleading successful AST?
Source: falgon/htcc — distributed by TomeVault.