Skip to content

Some exotic constraints are missing corresponding signature constructs #675

@kbattocchi

Description

@kbattocchi

Constructor constraints with more than 0 arguments and member constraints with or clauses containing at least one concrete type can be generated by F# programs, but passing the --sig option to the F# compiler results in a malformed signature file because these constructs aren't part of the grammar for signatures.

For example, given this file:

let inline f() = (^t : (new : int -> ^t) 5)
let inline g t u = ((^t or ^u) : (static member (^*^) : ^t * ^u -> ^v)(t, u)) // ok
let inline h u = g 1 u // static-typars portion of inferred constraint is (int or ^u)

--sig results in a signature file like this:

//error FS0010: Unexpected symbol '(' in member signature
val inline f : unit ->  ^t when  ^t : (( .ctor ) : int ->  ^t)
val inline g :
  t: ^t -> u: ^u ->  ^v
    when ( ^t or  ^u) : (static member ( ^*^ ) :  ^t *  ^u ->  ^v)
// error FS0010: Unexpected identifier in type constraint. Expected infix operator, quote symbol or other token.
val inline h :
  u: ^a ->  ^b when (int or  ^a) : (static member ( ^*^ ) : int *  ^a ->  ^b)

but this isn't a valid signature file because the definitions of f and h have invalid syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature RequestImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions