Skip to content

Unnest: existing-LET handling #273

Description

@jimmytacks

Part of #269 — spec 0009 (specs/0009-unnest-to-let.md). Depends on #271 (engine), #272 (dialog).

Extend /Unnest to handle a formula that is already a =LET(...). Its own PR so it can't destabilise the core non-LET path.

Scope:

  • Parse the LET via the existing LetParser (shallow — top-level bindings).
  • Parse the body and each calculation binding's RHS with the new expression parser (Unnest: formula expression parser (AST) #270), exploding their nested step candidates into new steps.
  • Insert new steps before the binding (or body) that first uses them, preserving existing bindings' names and relative order.
  • Existing value bindings left untouched (already inputs).
  • On FormatException from LetParser, refuse with the same error wording ConvertLetToLambdaCommand uses — no dialog.

Fallback: if re-parenting steps across existing bindings proves fiddly, scope v1 to body-only explosion (flag on the parent if so).

Tests

  • Existing tidy LET -> body + calc-binding RHSs exploded; value bindings preserved
  • New steps inserted before first use; existing binding order preserved
  • Malformed LET -> refuse with clear error, no dialog
  • Round-trip through LetParser

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions