bug: CLI readAll stops reading at first empty line instead of reading to EOF

Open Beginner friendly
#22 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Domain
cli

Research direction

Start with the readAll helpers in cli/LckJsonFmt.lean and cli/LckJsonTree.lean, then inspect how each CLI reads stdin. Verify the behavior with input containing a blank line and confirm that reading continues through blank lines and ends only at EOF without truncating the JSON.

Written by the indexing model from the issue text.

Description

Problem

Both cli/LckJsonFmt.lean and cli/LckJsonTree.lean define a readAll helper that reads stdin line-by-line, stopping as soon as it reads an empty line:

repeat
  let line ← stdin.getLine
  if line.isEmpty then break   -- WRONG: also breaks on blank lines mid-input
  buf := buf ++ line

This means any JSON that contains a blank line (e.g., pretty-printed JSON piped from another tool, or JSON with embedded newlines before/after values) will be silently truncated.

Expected fix

Read until EOF. IO.Stream.getLine returns "" on EOF — use IO.Stream.isEof or check for EOF after each read instead of treating an empty line as the terminator. Example:

repeat
  let line ← stdin.getLine
  if (← stdin.isEof) then break
  buf := buf ++ line

References

  • Flagged by AI code review on PR #8
Dominant language
Lean
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lambdaclass/lambda_compiler_kit

All issues in lambdaclass/lambda_compiler_kit

Similar issues

More CLI issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.