Civet icon indicating copy to clipboard operation
Civet copied to clipboard

Maximum call stack size exceeded

Open mixty1 opened this issue 1 year ago • 1 comments

I got this error on playground and locally, with the same code

mixty1 avatar Jan 11 '24 21:01 mixty1

Thanks for the report, definitely a bug!

Looks like a combinatoric explosion in the parser from the way nested arguments and nested objects interact.

STRd6 avatar Jan 13 '24 22:01 STRd6

Just hit this issue again today. Here's a more minimal reproduction:

defaultColors :=
    50: '#f8fafc'
    100: '#f1f5f9'
    200: '#e2e8f0'
    300: '#cbd5e1'
    400: '#94a3b8'
    500: '#64748b'
    600: '#475569'
    700: '#334155'
    800: '#1e293b'
    900: '#0f172a'
    950: '#020617'
    50: '#f9fafb'
    100: '#f3f4f6'
    200: '#e5e7eb'
    300: '#d1d5db'
    400: '#9ca3af'
    500: '#6b7280'
    600: '#4b5563'
    700: '#374151'
    800: '#1f2937'
    900: '#111827'
    950: '#030712'
    50: '#fafafa'
    100: '#f4f4f5'
    200: '#e4e4e7'
    300: '#d4d4d8'
    400: '#a1a1aa'
    500: '#71717a'
    600: '#52525b'
    700: '#3f3f46'
    800: '#27272a'
    900: '#18181b'
    950: '#09090b'
    50: '#fafafa'
    100: '#f5f5f5'
    200: '#e5e5e5'
    300: '#d4d4d4'
    400: '#a3a3a3'
    500: '#737373'
    600: '#525252'
    700: '#404040'
    800: '#262626'
    900: '#171717'
    950: '#0a0a0a'
    50: '#fafaf9'
    100: '#f5f5f4'
    200: '#e7e5e4'
    300: '#d6d3d1'
    400: '#a8a29e'
    500: '#78716c'
    600: '#57534e'
    700: '#44403c'
    800: '#292524'
    900: '#1c1917'
    950: '#0c0a09'
    50: '#fef2f2'
    100: '#fee2e2'
    200: '#fecaca'
    300: '#fca5a5'
    400: '#f87171'
    500: '#ef4444'
    600: '#dc2626'
    700: '#b91c1c'
    800: '#991b1b'
    900: '#7f1d1d'
    950: '#450a0a'
    50: '#fff7ed'
    100: '#ffedd5'
    200: '#fed7aa'
    500: '#f59e0b'
    600: '#d97706'

It doesn't need multiple levels of nesting, just a long object.

STRd6 avatar Jun 03 '24 01:06 STRd6

I've been exploring traces for this, and I think I understand part of it:

  • Each successive line is being considered as a possible implicit call from the previous line. (I'm not yet sure what causes these considerations to fail, but it happens late enough in the process that the consideration is recursive through all the lines.)
  • In particular, IndentedFurther is matching on every line.
  • In particular, this means we're not doing an initial PushIndent. I'm amazed that the object literal parses at all...
  • We do successfully PushIndent for a while, but then ExpressionizedStatementWithTrailingCallExpressions fails to match the implicit object literal. It seems like NestedNonAssignmentExtendedExpression should check for more than just expressionized statements.
  • Even ignoring this, I believe when we match IndentedFurther (as part of ApplicationStart) we should also PushIndent for the duration of the arguments. We don't seem to currently, so these n lines of equal indentation gets treated like its nested n levels. So this leads to a very deep parse stack.

edemaine avatar Jun 25 '24 14:06 edemaine