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

Improve error reporting: Let as last line in block #1162

Closed
Tracked by #1103
isaacabraham opened this issue May 9, 2016 · 3 comments · Fixed by #1164
Closed
Tracked by #1103

Improve error reporting: Let as last line in block #1162

isaacabraham opened this issue May 9, 2016 · 3 comments · Fixed by #1164

Comments

@isaacabraham
Copy link
Contributor

What

(From @tpetricek). The following code snippet leads to the resulting error message: -

let sum = 0
for x in 0 .. 10 do
    let sum = sum + x

error FS0588: Block following this 'let' is unfinished. Expect an expression.

Why

The above error message, whilst factually correct, does not explain to the beginner what this is and why it occurs. There are of course two errors here - one that the user is trying to mutate a value (which should be ignored from this issue as it is covered elsewhere) and the second which is that there is no result from the block.

How

Suggest: Every code block is an expression and must have a result. 'let' is not an expression and cannot be the final code element in a block. Consider returning something explicit from this block.

@kurtschelfthout
Copy link
Contributor

kurtschelfthout commented May 9, 2016

Is this saying that ignore is never an option? I'm not sure that is the case but also I can't come up with a really convincing counter-example so perhaps it is. ConcurrentDictionary.TryRemove perhaps? MethodBase.Invoke on a void method?

Ignore me. Thoroughly confused with another error. Time for coffee!

@isaacabraham
Copy link
Contributor Author

@kurtschelfthout not sure I follow. Ignore should be valid - it would just return unit from the block.

@forki
Copy link
Contributor

forki commented May 9, 2016

PR in #1164

forki added a commit to forki/visualfsharp that referenced this issue May 9, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 9, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 9, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 9, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 9, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 9, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 9, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 9, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 10, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 10, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 10, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 12, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 12, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 12, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 12, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 12, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 13, 2016
forki added a commit to forki/visualfsharp that referenced this issue May 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants