Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing Error: From the end slicing #12424

Closed
auslavs opened this issue Nov 19, 2021 · 0 comments · Fixed by #12427
Closed

Confusing Error: From the end slicing #12424

auslavs opened this issue Nov 19, 2021 · 0 comments · Fixed by #12427

Comments

@auslavs
Copy link

auslavs commented Nov 19, 2021

I was naively expecting that 'from the end slicing and indexing' would be moved from F#5 Preview to F#6.

But when trying out the following code (taken from F# RFC FS-1076) produces a compiler error when using F# 6.

let list = [1;2;3;4;5]

list.[..^0]   // 1,2,3,4,5
list.[..^1]   // 1,2,3,4
list.[0..^1]  // 1,2,3,4
list.[^1..]   // 4,5
list.[^0..]   // 5
list.[^2..^1] // 3,4

Compiler error:
"From the end slicing with requires language version 5.0, use /langversion:preview."

I've since learned that this is not yet included in F#6, but it is still in the preview of the language, so I think this should be changed to:
"From the end slicing with requires language version 6.0, use /langversion:preview."

Provide the steps required to reproduce the problem:

Either use your IDE to get error feedback or run dotnet build to view the errors

If possible attach a zip file with the repro case. This often makes it easier for others to reproduce.
The zip file should ideally represent the situation just before the call/step that is problematic.

Expected behavior

Error should be:
"From the end slicing with requires language version 6.0, use /langversion:preview."

Actual behavior

Compiler error:
From the end slicing with requires language version 5.0, use /langversion:preview.

Known workarounds

You can still set <LangVersion>preview</LangVersion> but the error is slightly misleading.

Related information

Provide any related information (optional):

  • Operating system

  • .NET Runtime kind (.NET Core, .NET Framework, Mono)
    .NET 6

  • Editing Tools (e.g. Visual Studio Version, Visual Studio)
    Visual Studio Code

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

Successfully merging a pull request may close this issue.

2 participants