compiler icon indicating copy to clipboard operation
compiler copied to clipboard

Table / Compiler: Error using nested loops inside table

Open getflourish opened this issue 1 year ago • 2 comments

What version of astro are you using?

1.4.2

Are you using an SSR adapter? If so, which one?

no

What package manager are you using?

npm

What operating system are you using?

macOS

Describe the Bug

I’m generating multiple tables (a, b, c) and inside each table looping through an array (1, 2, 3) to generate some rows. If there is any kind of element after that (trailing section), the compiler fails.

<section>
  {["a", "b", "c"].map(char=> {
    <table>
      <tbody>
        {[1, 2, 3].map((num) => (
          <tr>{num}</tr>
         ))}
      </tbody>
    </table>
})}
</section>
<section></section>

I expect 3 table with 3 rows each.

Error


goroutine 21 [running]:
github.com/withastro/compiler/internal.inTableIM(0x605d40)
        github.com/withastro/compiler/internal/parser.go:1729 +0xaf
github.com/withastro/compiler/internal.(*parser).parseCurrentToken(0x605d40)
        github.com/withastro/compiler/internal/parser.go:2899 +0x13
github.com/withastro/compiler/internal.(*parser).parse(0x605d40)
        github.com/withastro/compiler/internal/parser.go:2926 +0x3
github.com/withastro/compiler/internal.ParseWithOptions({0x746c0, 0x66f060}, {0x0, 0x0, 0x0})
        github.com/withastro/compiler/internal/parser.go:2986 +0x18
github.com/withastro/compiler/internal.Parse(...)
        github.com/withastro/compiler/internal/parser.go:2943
main.Transform.func1.1.1({0x676c80, 0xc3e}, 0x67a000, 0x40b920, {{}, 0x7ff80004000000de, 0x673cd0})
        ./astro-wasm.go:247 +0xb
created by main.Transform.func1.1
        ./astro-wasm.go:244 +0x3
exit code: 2

The reproduction on StackBlitz crashes pretty badly.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-pewwat-pqgh8e?file=src%2Fpages%2Findex.astro&on=stackblitz

Participation

  • [ ] I am willing to submit a pull request for this issue.

getflourish avatar Oct 04 '22 07:10 getflourish

The same code works when all table elements are replaced with div. Also, it doesn’t seem to matter if there are td inside tr.

getflourish avatar Oct 04 '22 07:10 getflourish

Thanks for the report! I'll take a look at this as soon as I can, seems like we still have some table bugs to track down. 😅

natemoo-re avatar Oct 05 '22 20:10 natemoo-re