Skip to content

Parser: flow-audio foundation conformance hits unexpected LBRACE #810

Closed

Description

@godofecht

Reproduction

From flooooooooooow/flow-audio, the conformance/foundation.flow case currently reaches the parser and reports:

Unexpected token in expression: TokenType.LBRACE

This surfaced while exercising the package locally via the root-project test/run path. It is distinct from the root-package self-import resolution bug tracked in #803: that issue blocks canonical flow_audio.* imports, while this case is a parser failure after reaching foundation.flow.

Current source audit (2026-08-29)

The current flow-audio/conformance/foundation.flow contains one expression-position typed brace literal that is the strongest minimization target:

let config: PrepareConfig = PrepareConfig {
    rate: rate,
    max_block_size: 64,
    event_capacity: 256
}

The other braces in the file are ordinary function/if blocks. Flow's compiler has an explicit AST_STRUCT_LIT representation and self-host monomorphization support for struct-literal nodes, so this should be treated as a focused parser/front-end compatibility failure rather than assuming brace literals are unsupported wholesale.

Expected behavior

The foundation conformance program should parse normally, or the parser should report the exact unsupported syntax construct with a focused diagnostic.

Next action

Reproduce locally from a clean flow + flow-audio checkout. First reduce the case to a tiny PrepareConfig { ... }-style typed struct literal using the same field syntax. If that reproduces Unexpected ... LBRACE, add the minimized parser regression and compare the production Python parser's struct-literal path with the Stage-A AST_STRUCT_LIT representation before changing grammar behavior. If it does not reproduce, bisect the preceding expression boundary in foundation.flow rather than changing struct-literal parsing speculatively.

Validation is local-only; do not use hosted CI/workflows for qualification.

Activity

  1. godofecht commented on Aug 27, 2026

    @godofecht
    ContributorAuthor

    I minimized the parser boundary behind this failure and archived the derivation + Flow witness in godofecht/OpenProjects.

    The important parser smell is in parse_primary(): any Identifier { speculatively enters parse_struct_literal(), catches any SyntaxError, rewinds lexer/token state, and returns the identifier as a variable. That behavior is currently exercised even by normal condition endings such as:

    if status != FLOW_AUDIO_OK { return 1 }
    

    because the final identifier is immediately followed by the body brace. The failed speculative struct parse sees return where it expected a field name, swallows the error, then lets parse_if() consume the brace.

    The cleaner grammar boundary is context-aware: at top level in an if/while condition, { is a FOLLOW token for the condition and should terminate the expression without attempting a struct literal. In ordinary expression context, Identifier { is committed struct-literal syntax and any inner parse error should propagate instead of being backtracked into a later bare-LBRACE error. Nested expressions reset to ordinary struct-literal-enabled context, so if accepts(Pair { a: 1 }) { ... } remains valid.

    I would implement this as a depth-scoped expression context (block_brace_terminates) used by parse_if/parse_while, and remove the catch-and-rewind for Identifier { in ordinary expression context.

    Minimal regressions: normal if status == 0 { ... }; valid Pair { a: 1 }; nested struct literal inside a condition; malformed Pair { a = 1 } must diagnose the bad = rather than degrade to Unexpected ... LBRACE.

    I cannot claim this is the sole cause of the current foundation failure until the parser is run locally after the change, but it is a definite diagnostic/grammar ownership bug and should either resolve #810 or expose the actual inner unsupported construct cleanly. Validation remains local-only; no hosted workflows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions