Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5929017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:21:55+00:00 2026-05-22T14:21:55+00:00

In the following dummy code, if I set a break point at the last

  • 0

In the following dummy code, if I set a break point at the last line, the variable x is not accessible in the debugger with:

the name x does not exist in the current context.

module main = 
    let x = 1
    printfn "%d" x
    1

But if I change the last line to 1|>ignore and set a break point there, I can see x = 1 in the debugger. How does F determine in the first case x is out of scope? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:21:56+00:00Added an answer on May 22, 2026 at 2:21 pm

    In this context, the x value is compiled as a static field of the main module (represented as a class).

    I think you should be always able to see it in the watches window if you enter Foo.main.x (where Foo is the namespace of your file – if you don’t provide namespace explicitly, this will be generated from the file name such as foo.fs in this case).

    Why do you see the variable if you add ignore? I’m not entirely sure – it is probably because the F# compiler sets the breakpoint to some place in the same class where x is placed (as a field). The lookup done by debugger follows the C# (.NET) rules, so it looks at the compiled code and not at the F# source code (because the F# integration doesn’t provide its own resolver).

    In general, you can assume that local variables can be viewed if you’re inside a function where they are declared. Captured variables in a closure can be usually accessed using this (which gives you reference to the closure object), but this may depend on some compiler internals.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following code does compile whereas name aNumber is not declared before use. class A
I have the following PHP code, but it's not working. I don't see any
I have the following scala code: package dummy import javax.servlet.http.{HttpServlet, HttpServletRequest => HSReq, HttpServletResponse
I have a small dummy project in VS 2008, contains only the following code
Suppose I have following code: def foo(s): A dummy function foo. For example: >>>
I'm unclear about return value of the following dummy code: function foo() var ret
Ok, I have the following code that used to work but now it does
I have the following T-SQL code: SET TRANSACTION ISOLATION LEVEL SERIALIZABLE BEGIN TRANSACTION T1_Test
I have the following code: Imports System.Data Imports System.Data.OleDb Partial Class Dummy Inherits System.Web.UI.Page
I have the following setup code: MockOf<IObjectSet<Dummy>>().Setup(c => c.AddObject(dummy)).Verifiable(); MockOf<IObjectContextWrapper>().Setup(c => c.GetObjectSet<Dummy>()).Returns(MockOf<IObjectSet<Dummy>>().Object); where Dummy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.