Skip to content

Formatter crashes on inline definition in parentheses #9046

@lukewilliamboswell

Description

@lukewilliamboswell

Summary

The roc fmt command crashes when encountering an inline definition inside parentheses followed by a method call, such as (x = 5).foo(). Instead of gracefully handling the parse error or preserving the original code, the formatter fails entirely.

Minimal Reproduction

(x = 5).foo()

Expected Behavior

The formatter should either:

  1. Report a clear syntax error indicating that inline definitions in expression context are not supported
  2. Gracefully preserve the original code when it cannot parse/format it

Actual Behavior

The formatter fails with cascading parse errors:

expected_expr_close_round_or_comma, at token CloseRound

Snapshot Test

A minimal reproduction test/snapshots/expr/inline_def_in_parens.md is attached

inline_def_in_parens.md

Metadata

Metadata

Assignees

Labels

formattingRelates to the roc formatter

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions