Zulip Chat Archive

Stream: general

Topic: Nested dot notation fails with type classes


pandaman (Dec 14 2024 at 12:39):

Hi. I came across a case where a nested dot notation results in a compiler error with type classes while it works with structures. Is this an intended behavior or should I open an Issue? Thanks!

Here is MWE. You can also run the code in Playground.

structure NFA where
  nodes : Array Unit

def NFA.pushRegex (nfa : NFA) : NFA := { nodes := nfa.nodes.push () }

namespace Class
class ProofData where
  nfa : NFA

def ProofData.nfa' [pd : ProofData] : NFA := pd.nfa.pushRegex

class Alternate extends ProofData where

variable [pd : Alternate]

-- Single dot works
example : NFA := pd.nfa'
/-
function expected at
  ProofData.nfa'
term has type
  NFA
-/
-- example : Array Unit := pd.nfa'.nodes
end Class

Daniel Weber (Dec 14 2024 at 15:00):

(pd.nfa').nodes also works :thinking:

pandaman (Dec 16 2024 at 10:57):

Reported as https://github.com/leanprover/lean4/issues/6400


Last updated: May 02 2025 at 03:31 UTC