Skip to content

Conversation

@nojaf
Copy link
Contributor

@nojaf nojaf commented Apr 14, 2022

Superseded #12980.
Some more nodes were introduced to better capture operators, active patterns and partial active patterns.

Very much still a work in progress. Feedback would be welcome if there are volunteers 😊.

@nojaf
Copy link
Contributor Author

nojaf commented Apr 19, 2022

FSharp.Core now builds so, I guess that is one step forward.
I'm currently hitting the following problem: my signature file no longer matches the implementation:
signature:

module WithSignature

val (|A|_|) : int -> string option

implementation:

module WithSignature

let (|A|_|) = function | 1 -> Some "1" | _ -> None

error:

       "C:\Users\nojaf\Projects\FSharpSampleProject\FSharpSampleProject.fsproj" (default target) (1:7) ->
       (CoreCompile target) ->
         C:\Users\nojaf\Projects\FSharpSampleProject\WithSignature.fs(3,6): error FS0034: Module 'WithSignature' contains↔    val (|A|_|) : (int -> string option)    ↔but its signature specifies↔    val (|A|_|) : int -> string option    ↔The arities in the signature and implementation differ. The signature specifies that '|A|_|' is function definition or lambda expression accepting at least 1 argument(s), but the implementation is a computed function value. To declare that a computed function value is a permitted implementation simply parenthesize its type in the signature, e.g.↔ val |A|_|: int -> (int -> int)↔instead of↔ val |A|_|: int -> int -> int. [C:\Users\nojaf\Projects\FSharpSampleProject\FSharpSampleProject.fsproj]

@auduchinok any ideas by any chance? I'm out of ideas.

The ValReprInfo of the implementation file has no implArgInfos, while the signature has one.
It fails in

elif not (nSigArgInfos <= implArgInfos.Length && List.forall2 (fun x y -> List.length x <= List.length y) sigArgInfos (fst (List.splitAt nSigArgInfos implArgInfos))) then
err(fun(x, y, z) -> FSComp.SR.ValueNotContainedMutabilityAritiesDiffer(x, y, z, id.idText, string nSigArgInfos, id.idText, id.idText))

but I'm unsure where the implVal.ValReprInfo is wrongly created.

@auduchinok
Copy link
Member

FSharp.Core now builds so, I guess that is one step forward.

This is very great, congrats!

@auduchinok any ideas by any chance? I'm out of ideas.

I hope I'll be able to look into it tomorrow and will let you know

@nojaf nojaf force-pushed the operator-syntax-tree-two branch from 9f4516e to 6dc2593 Compare April 20, 2022 07:17
@nojaf nojaf force-pushed the operator-syntax-tree-two branch from 8a5b606 to 84545ec Compare April 21, 2022 08:44
@nojaf
Copy link
Contributor Author

nojaf commented Apr 21, 2022

I'm currently in a dilemma here:

type MyType() =
    static member (|
        AA
    |) = 2
    static member (|
        BB|_
    |) = Some 3

In the current compiler this works out fine, but given there is more information I'm not (rightly) bumping into

let envinner =
match apinfoOpt with
| Some (apinfo, apOverallTy, m) ->
if Option.isSome memberFlagsOpt || (not apinfo.IsTotal && apinfo.ActiveTags.Length > 1) then
error(Error(FSComp.SR.tcInvalidActivePatternName(), mBinding))
apinfo.ActiveTagsWithRanges |> List.iteri (fun i (_tag, tagRange) ->
let item = Item.ActivePatternResult(apinfo, apOverallTy, i, tagRange)
CallNameResolutionSink cenv.tcSink (tagRange, env.NameEnv, item, emptyTyparInst, ItemOccurence.Binding, env.AccessRights))
{ envinner with eNameResEnv = AddActivePatternResultTagsToNameEnv apinfo envinner.eNameResEnv apOverallTy m }
| None ->
envinner

Where Option.isSome memberFlagsOpt is rightly true.

Concretely I'm hitting this error in:

static member (|
AA
|) = (|
Lazy
|)
static member (|
BB
|) = ActivePatterns.(|
AA
|)
static member (|CC|) =
if true then ignore ActivePatterns.(|
AA
|)

@dsyme and others, any thoughts?

@nojaf nojaf force-pushed the operator-syntax-tree-two branch from 0065752 to 9ea0b09 Compare April 22, 2022 15:28
@nojaf
Copy link
Contributor Author

nojaf commented May 2, 2022

Closing in favour of #13057.

@nojaf nojaf closed this May 2, 2022
@nojaf nojaf deleted the operator-syntax-tree-two branch May 31, 2022 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants