dotnet / dotnet/fsharp

Having an @-sign in a let-binding removes the rest of the name, but not in type members

Open
#7,784 4 comments 0 reactions 0 assignees View on GitHub
Area-Compiler-Checking Bug Impact-Low
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

An `@` sign in a let-binding removes the rest of the name, and replaces it with a number (typically: the line number).

**Repro steps**
Consider this (1):

```f#
type Tests() =
[]
static member``This is a test with @sign in it`` () = Assert.True(true)
```

And this (2):

```f#
module Tests=
[]
let ``This is a test with @sign in it`` () = Assert.True(true)
```

(1) compiles to `Tests.``This is a test with @sign in it`` `
(2) compiles to `Tests.``This is a test with @35`` ` (depending on line number)

**Expected behavior**

Both let bindings and members should be treated the same way. After all, they can both be public identifiers and consumed from a library.

A compiler warning (as per F# spec), but other than that, the name should be left untouched. I'm aware that F# compiles lambdas etc to to methods with special names including the `@`-sign, but the risk of name clashes should be for the programmer, right?

**Actual behavior**

The name is garbled and shortened, which looks surprising and, especially with the feature of the doubly backticked long names, it is a pity this cannot be left untouched.

**Known workarounds**

Don't use public let-bindings for tests (or whenever you need to use a `@`-sign in the name).

**Related information**

I would assume this is due to the internals of F# that typically only apply to internal F# generated identifiers and for some reason it thinks this name is also a generated name (which it clearly isn't, so I'm just wondering why it gets the lambda-treatment).

Seen on recent F# versions, may also happen on older versions, I didn't check.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.