-
Notifications
You must be signed in to change notification settings - Fork 854
Description
The ways in which global as pseudo-namespace can be used are murky:
- When used with a DU you cannot specify the type name
- When used with record fields, it doesn't work at all
Repro steps
Use of global with DU fields:
This works (susprisingly so, but I do see some logic in allowing this):
type MyDU = X of string
module Test =
let useGlobalPrefix = global.X "foo" // succeedsThis does not (but should):
type MyDU = X of string
module Test =
let useGlobalPrefix = global.MyDU.X "foo" // failsThe above should work on the grounds that MyDU.X "foo" is valid syntax, and in the root namespace, meaning I should be able to prefix it with global.
Use of global with record fields
Using global never works when used with record fields.
type MyRec = { A : string }
module Test =
let useGlobalPrefix1 = { global.MyRec.A = "foo" } // fails
let useGlobalPrefix2 = { global.A = "foo" } // failsExpected behavior
Use of global should be accepted as it is there to be able to distinguish conflicting qualified names through their full path. Whether or not I put the above code in a namespace, it fails when prefixed with global and used on a field.
Actual behavior
It shows an error which tells me what I should do with global, but I actually already did:
error FS1126: 'global' may only be used as the first name in a qualified path
Known workarounds
Use type aliases: the problem does not happen is you alias a type with global as the prefix.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status