Skip to content

F# script fails only on second evaluation. #17124

Description

@goswinr

I encountered some odd scripting behavior.
Given a library with same namespace and module name, or same nested module names:

module A = 
    [<RequireQualifiedAccess>]
    module A = 
        let x = 42

Running this script works fine on first run

open A
A.x

, but fails in second run:

  open A
  -----^

stdin(7,6): error FS0892: This declaration opens the module 'FSI_0002.A.A', which is marked as 'RequireQualifiedAccess'. Adjust your code to use qualified references to the elements of the module instead, e.g. 'List.map' instead of 'map'. This change will ensure that your code is robust as new constructs are added to libraries.

I know why this happens. On the second run, the top level module or namespace is already open, so the open statement tries to open the nested one and fails. Is there a way to make opening of namespaces work in such a scenario? Like requiring the open statement to be fully qualified?
In my use case, I am actually evaluating a script via FCS repeatedly. This script is referencing such a nuget package where namespace and module have the same name.
image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions