Skip to content

Can't retrieve a toplevel table from a local struct field and index it? #1333

Open

Description

@axch

This is a minimization of the problem @emilyfertig encountered in #1332. The chain of interactions is to make a table, make a struct containing that table, then access that field of the struct and try to index the table. Oddly, if we do all of these steps at the top level, it works fine:

struct Foo(n|Ix) = foo : (n=>Float)

table : (Fin 2=>Float) = [1., 2.]

x = (Foo table)

x.foo[0@(Fin 2)]
> 1.

But if we make the struct construction local, we get a compiler error:

:p
  y = (Foo table)
  y.foo[0@(Fin 2)]
> Compiler bug!
> Please report this at github.com/google-research/dex-lang/issues
>
> Unexpected table: table
> CallStack (from HasCallStack):
>   error, called at src/lib/Simplify.hs:570:22 in dex-0.1.0.0-Gi9B8TxRbicLQnuTnmjlXJ:Simplify

That line number is in simplifyTabApp, which can't handle the table being a Var that's not wrapped in SimpInCore, which is what, in this example, it is getting.

@dougalm help?

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions