Skip to content

Parser: subscripts in a flat list literal accumulate nesting depth ("expression nesting too deep" on 300 x E[0]) #1655

Description

@InauguralPhysicist

The parser rejects a flat list literal whose elements contain subscripts, reporting "expression nesting too deep", even though nothing in it nests. Found by EigenLua round 2, which emits upvalues as cell subscripts (c5[0]): a Lua call or table constructor that references about 250 upvalues stops compiling.

Reproducer (main @ 686d3b7)

E is [1]
x is [E[0], E[0], ... 300 times ...]        # Parse error: expression nesting too deep
y is [(E), (E), ... 300 times ...]           # fine
z is [E[0] + 1, ... 127 times ...]           # already refused at 127

Full file: EigenLua gaps/subscript-nesting.eigs (branch frontend/r2). Measured counts:

  • plain-sub: 200 elements OK, 300 refused;
  • sum-sub: 100 elements OK, 127 refused;
  • paren: 300 elements OK.

Each subscript appears to consume a nesting level that is never returned when the element finishes, so the depth counter tracks the total number of subscripts in the expression, not the actual depth.

Done when

  • The nesting depth is measured as depth: a flat list of N subscripted elements parses for any N the other limits allow.
  • A regression test covers 1000 E[0] elements and 1000 E[0] + 1 elements.
  • Real deep nesting is still refused at the same limit.

No activity

Activity on this issue will appear here.

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions