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

Applications of the function are parsed in the body of the interface #3472

Open
spcfox opened this issue Jan 21, 2025 · 1 comment
Open

Applications of the function are parsed in the body of the interface #3472

spcfox opened this issue Jan 21, 2025 · 1 comment

Comments

@spcfox
Copy link
Contributor

spcfox commented Jan 21, 2025

Steps to Reproduce

interface Iface where
  foo x y

Expected Behavior

Parsing error

Observed Behavior

This code produces empty interface:

Main> :doc Iface
interface Main.Iface : Type
@buzden
Copy link
Collaborator

buzden commented Jan 23, 2025

foo x y may be parsed as a forward declaration of an implementation of an interface foo:

interface foo (0 a, b : Type) where

foo x y

works.

But it still seems to not to make sense in interface declarations.

Interestingly, we can have data forward declaration in interfaces, but they behave as a usual functions:

interface X (0 x, y : Type) where
  %inline
  foo x y -- ignored
  data Y : Type

X Nat Nat where
  Y = Nat

If we try to add a data declaration according to the forward declaration in the interface, we get a strange error:

failing "Missing methods in X: Y"
  X String String where
    data Y : Type where
      MkY : Y

But if we add another declaration for Y, we can see that "missing methods" checks earlier than "can only contain definitions":

failing "Implementation body can only contain definitions"
  X String String where
    Y = Nat
    data Y : Type where
      MkY : Y

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

No branches or pull requests

3 participants