Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
axch opened this issue Jul 26, 2023 · 0 comments
Open

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

axch opened this issue Jul 26, 2023 · 0 comments

Comments

@axch
Copy link
Collaborator

axch commented Jul 26, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant