dotnet / dotnet/vblang

Unassigned variable warning reported when passing variables intended as `Out` arguments

Open
#67 11 comments 8 reactions 0 assignees View on GitHub
Scenario
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

@paul1956 commented on [Wed Jun 08 2016](https://github.com/dotnet/roslyn/issues/11880)

**Version Used**:
VS 2015 Update 2
**Steps to Reproduce**:
1. Declare Function with attribute.

```
Public Function Return6( ByRef LastErrorMessage As String) As Integer
LastErrorMessage = "None"
Return 6
End Function
```
1. Call Function

```
Six = Return6 (ReturnError)
```

**Expected Behavior**:
No Warnings, I don't want to have to assign a default value to an Out variable like ReturnError to make the warning disappear.
**Actual Behavior**:

```
Warning BC42030 Variable 'ReturnError' is passed by reference before it has been assigned a value. A null reference exception could result at runtime.
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.