Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit open namespaces, modules, types to debug data #1003

Closed
KevinRansom opened this issue Mar 8, 2016 · 3 comments · Fixed by #12817
Closed

Emit open namespaces, modules, types to debug data #1003

KevinRansom opened this issue Mar 8, 2016 · 3 comments · Fixed by #12817
Labels
Area-Debug stepping, debug points, stacks and more Feature Improvement Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Milestone

Comments

@KevinRansom
Copy link
Member

Per @dsyme:

The PDB format has an entry that F# has never filled in for the "open namespaces" within a method scope. This records the active "using" statements for a piece of code. I believe this entry is used to help interpret the stuff entered into the "Watch" and "Immediate" windows of the VS debugger. So if in C# you have "using System" then you can put "Console.In" in the watch window

In F# I think this doesn't work - but only because we never fill in the "open namespaces" entry in the PDB format and write them out. I assume there is a matching "TODO" in the portable PDB and MDB debug formats. It would be good to plan ahead at this point and make sure the basic writers can emit this information, and then plumb it through fromm the type checker at a later point.

The "open namespaces" information wouldn't be too hard to propagate down. But we've just never done it.

@dsyme dsyme added Area-Compiler Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. labels Apr 8, 2016
@dsyme dsyme added Feature Improvement and removed Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. labels Sep 8, 2017
@cartermp cartermp added this to the Unknown milestone Aug 25, 2018
@dsyme dsyme added Area-Debug stepping, debug points, stacks and more and removed Area-Compiler labels Aug 20, 2021
@dsyme
Copy link
Contributor

dsyme commented Aug 20, 2021

I'm working on this, but there are some additional angles to consider, I'll note them here

Inside scope:

  • support open Abc where the module implicitly gets a mangled name AbcModule and if necesary emit both an open Abc on a namespace and module with same name

  • make sure open type works

  • Make sure AutoOpen works

  • Make sure top-level initialization code gets correct open

  • Make sure class constructors get correct open

  • Make sure let on functions within classes get correct open context

Outside of scope:

  • support type X = int alias support for F# (may need PDB format extension)

  • support module X = FSharp.Core.Operators alias support for F# (may need PDB format extension)

  • When we do an F# expression evaluator, make sure open Foo on F#-defined extension methods works

  • When we do an F# expression evaluator, make sure open Foo on F# modules containing unions works

  • Consider what to do about CompiledName in FSharp.Core

@dsyme dsyme changed the title PDB Generation - propagate open namespaces to symbol data Propagate open namespaces to debug data Aug 23, 2021
@dsyme dsyme added the Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language. label Sep 16, 2021
@dsyme dsyme changed the title Propagate open namespaces to debug data Emit open namespaces to debug data Feb 18, 2022
@dsyme
Copy link
Contributor

dsyme commented Mar 1, 2022

@vzarytovskii and I made progress on this in this branch: https://github.com/dsyme/fsharp/tree/imports

@dsyme dsyme changed the title Emit open namespaces to debug data Emit open namespaces, modules, types to debug data Mar 1, 2022
@dsyme
Copy link
Contributor

dsyme commented Mar 1, 2022

@vzarytovskii Here are the fragments of test code for this

namespace A

// TEST: implicit open of namespace A

open System

module InitCode1 =
    open System.Collections.Generic
    let v = Environment.HasShutdownStarted  // TEST - BUG - Initialization code doesn't seem to have open declarations recorded

    printfn "hello"

module InitCode2 =
    open System
    let v = Environment.HasShutdownStarted  // TEST - BUG - Initialization code doesn't seem to have open declarations recorded

    printfn "hello"

module Helpers =
   let someValue = 1 
   let someValueRedefinedAfter = 1 

[<AutoOpen>]
module AutoOpenHelpers =
   let someAutoOpenValue = 1 

module M = 
    open System.Collections.Generic
    open Helpers

    let f() =
        System.Environment.HasShutdownStarted |> ignore // TEST
        Environment.HasShutdownStarted |> ignore // TEST
        someValue |> ignore // TEST

        someValueRedefinedAfter |> ignore // TEST - BUG - This should show value "1"

        Operators.nan |> ignore // TEST - BUG - CompiledName stuff in FSharp.Core means this doesn't work

        Helpers.someValue |> ignore // TEST - BUG - no emit of implicit open of namespace A
       
        someAutoOpenValue |> ignore // TEST - BUG - doesn't know about AutoOpen

    let someValueRedefinedAfter = 0xBAAD

    f()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Debug stepping, debug points, stacks and more Feature Improvement Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants