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

Type checking issue with Idris2 Load instruction in dependent context #3259

Open
weiserhase opened this issue Apr 16, 2024 · 1 comment
Open

Comments

@weiserhase
Copy link

I've encountered a potential type checking bug in Idris2. The issue arises specifically with the Load instruction when it takes an Int argument and operates within a dependent type context. (I did report the issue in the idris2 discord)

Steps to Reproduce

Attempt to compile the provided code snippet.

data Heap : (fs : Maybe a) -> Type where 
data Instr : Heap ht -> Type where
  Load : Int -> Instr hp

Expected Behavior

The code should compile successfully.

Observed Behavior

The type checker produces an error regarding the Load instruction.
Removing the Int -> portion of the Load type signature allows the code to compile.
This issue was initially discovered within a larger Bytecode Interpreter project.
User @dunham provided this simplified example and offered some analysis.

@dunhamsteve
Copy link
Contributor

So this compiles fine:

data Heap : (fs : Maybe a) -> Type where 
data Instr : Heap ht -> Type where
  Load : Instr hp

but this gives us an error:

data Heap : (fs : Maybe a) -> Type where 
data Instr : Heap ht -> Type where
  Load : (z : Int) -> Instr hp

The error shows we can't implicitly bind ht because its type uses an implicit which is abstracted over z. and z is no longer in scope.

Error: While processing constructor Load. 
Can't bind implicit Main.{ht:829} of type (Prelude.Types.Maybe ?Main.{a:828}_[z[0]])

Aside from "oh well", one idea that comes to mind is to solve a:828 with a new implicit a that doesn't depend on z (if the type of a:828 doesn't reference z). I don't know if this is correct or worth the complexity.

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

2 participants