Skip to content

Members using overloaded operators defined over member's containing type require unsatisfiable constraint #968

Closed

Description

@drvink
type hoop< ^a when ^a : (static member (+) : ^a * ^a -> ^a) > = {
  Group1 : ^a;
  Group2 : ^a
} with
  static member inline (+) (x, y) = x.Group1 + y.Group2
end

let z = { Group1 = 1; Group2 = 2 } + { Group1 = 2; Group2 = 3 } // ok

type hoop with
  member inline this.Sum = this.Group1 + this.Group2 // A type parameter is missing a constraint 'when ( ^a or  ^?104290) : (static member ( + ) :  ^a *  ^?104290 ->  ^?104291)'
end

Activity

  1. kbattocchi commented on Feb 19, 2016

    @kbattocchi
    Contributor

    Marking Sum as inline fixes this problem, although it makes it clear that your definition of (+) is more general than you probably intended. I'm not sure if the inference failure is really a bug or just an extremely hard to understand error message.

  2. drvink commented on Feb 22, 2016

    @drvink
    ContributorAuthor

    Er, apologies, I pasted the wrong version of the code; it was supposed to have inline. The issue is not that it doesn't work without inline--that's fine, and not what I meant to point out--but rather the spurious warning that you get from the definition of that member.

  3. added
    Impact-Low
    on Jul 18, 2016
  4. added this to the Unknown milestone on Aug 25, 2018
  5. dsyme commented on Nov 5, 2021

    @dsyme
    Contributor

    Treating this as a duplicate of #385

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-Low

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions