Pseudo namespace "global" fails when used with specifying record fields, and acts odd with DU fields
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
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):
```f#
type MyDU = X of string
module Test =
let useGlobalPrefix = global.X "foo" // succeeds
```
This does not (but should):
```f#
type MyDU = X of string
module Test =
let useGlobalPrefix = global.MyDU.X "foo" // fails
```
The 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.
```f#
type MyRec = { A : string }
module Test =
let useGlobalPrefix1 = { global.MyRec.A = "foo" } // fails
let useGlobalPrefix2 = { global.A = "foo" } // fails
```
## Expected 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.
Contributor guide
Assessment
This issue has not been assessed yet.