bug: .fizz file with no statements crashes the parser with a traceback

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, python
Domain
backend, compilers

Research direction

Start in parser/BuildAstVisitor.py, especially visitRoot, visitFile_input, and get_source_info, which appear in the traceback. Reproduce with the empty.fizz, zero-byte, newline-only, and front-matter-only inputs described in the issue, then trace how the parser represents an empty file. Done when these inputs compile without a Python traceback and a focused regression test covers the behavior.

Written by the indexing model from the issue text.

Description

fizzbee 0.5.4 from the tap, macos 26, arm64.

a .fizz file with no statements fails compilation with a python traceback.

$ printf '# todo\n' > empty.fizz
$ fizz empty.fizz
Traceback (most recent call last):
  ...
  File ".../parser/BuildAstVisitor.py", line 29, in visitRoot
    return self.visitFile_input(ctx.getChild(0))
  File ".../parser/BuildAstVisitor.py", line 38, in visitFile_input
    file = ast.File(source_info=get_source_info(ctx))
  File ".../parser/BuildAstVisitor.py", line 1389, in get_source_info
    start = ast.Position(line=ctx.start.line, column=ctx.start.column+1)
AttributeError: 'TerminalNodeImpl' object has no attribute 'start'
Error: Compilation failed

same result for a zero-byte file, a file with a single newline, and a file with only front matter. not tried on main.

Dominant language
Go
Stars
361
Forks
24
Avg merge
1d 3h
Merged PRs (30d)
62

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

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 fizzbee-io/fizzbee

All issues in fizzbee-io/fizzbee

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.