Skip to content

Go to Definition doesn't work for user-defined operators on dev15 #1706

@cartermp

Description

@cartermp
  1. Install dev15 rel or prerel with .NET Desktop and create a new F# project.
  2. Open an F# script file with the following code (lifted from FSharpx Strings.fs):
open System

// Active patterns & operators for parsing strings
let (@?) (s:string) i = if i >= s.Length then None else Some s.[i]

let inline satisfies predicate (charOption:option<char>) = 
    match charOption with 
    | Some c when predicate c -> charOption 
    | _ -> None

let (|EOF|_|) = function 
    | Some _ -> None
    | _ -> Some ()

let (|LetterDigit|_|) = satisfies Char.IsLetterOrDigit
let (|Upper|_|) = satisfies Char.IsUpper
let (|Lower|_|) = satisfies Char.IsLower

/// Turns a string into a nice PascalCase identifier
let niceName (s:string) = 
    if s = s.ToUpper() then s else
    // Starting to parse a new segment 
    let rec restart i = seq {
        match s @? i with 
        | EOF -> ()
        | LetterDigit _ & Upper _ -> yield! upperStart i (i + 1)
        | LetterDigit _ -> yield! consume i false (i + 1)
        | _ -> yield! restart (i + 1) }

    // Parsed first upper case letter, continue either all lower or all upper
    and upperStart from i = seq {
        match s @? i with 
        | Upper _ -> yield! consume from true (i + 1) 
        | Lower _ -> yield! consume from false (i + 1) 
        | _ -> yield! restart (i + 1) }
    // Consume are letters of the same kind (either all lower or all upper)
    and consume from takeUpper i = seq {
        match s @? i with
        | Lower _ when not takeUpper -> yield! consume from takeUpper (i + 1)
        | Upper _ when takeUpper -> yield! consume from takeUpper (i + 1)
        | _ -> 
            yield from, i
            yield! restart i }
    
    // Split string into segments and turn them to PascalCase
    seq { for i1, i2 in restart 0 do 
            let sub = s.Substring(i1, i2 - i1) 
            if Seq.forall Char.IsLetterOrDigit sub then
                yield sub.[0].ToString().ToUpper() + sub.ToLower().Substring(1) }
    |> String.concat ""

Place the cursor on any use of @? in the match expressions and press f12.

Expected: Find Symbol Results the line where @? is defined..
Actual: Popup saying "Cannot navigate to the symbol under the caret."

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions