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

Nested dot notation results in a type error with type class instances #6400

Open
3 tasks done
pandaman64 opened this issue Dec 16, 2024 · 0 comments
Open
3 tasks done
Labels
bug Something isn't working

Comments

@pandaman64
Copy link

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

In the following code, c.foo.x will result in an error like function expected at Class.foo term has type S. While adding a paren like (c.foo).x passes. To reproduce the issue, using instance variables like [c : Class] seems necessary, i.e., taking an instance as a regular argument (c : Class) works.

structure S where
  x : Nat

class Class where
  s : S

def Class.foo [c : Class] : S := c.s

-- Single dot works
example [c : Class] : S := c.foo
-- Works with paren
example [c : Class] : Nat := (c.foo).x
/-
function expected at
  Class.foo
term has type
  S
-/
example [c : Class] : Nat := c.foo.x

Context

This issue is also discussed in Zulip.

Steps to Reproduce

  1. Go to Playground

Expected behavior: All examples should pass type check.

Actual behavior: c.foo.x fails with a type error.

Versions

Lean 4.16.0-nightly-2024-12-16

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@pandaman64 pandaman64 added the bug Something isn't working label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant