dotnet / dotnet/vblang

Boolean literals operations can differ from Boolean variable operations

Open
#100 5 comments 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

Possible bug (or by design?)

```
Dim boolFactory As BooleanFactory

Dim operand1 = boolFactory.GetBool(1)
Dim operand2 = boolFactory.GetBool(2)

Dim result As Boolean

result = operand1 ' result is True
result = operand2 ' result is True

result = operand1 = True ' result is True
result = operand2 = True ' result is True

result = operand1 = operand2 ' result is False

result = operand1 And operand2 ' result is False
result = operand1 And True ' result is True
result = operand2 And True 'result is False

result = operand1 AndAlso operand2 'result = True
```

```

Public Structure BooleanFactory
Public value As Int32
Public bool As Boolean

Public Function GetBool(ByVal seed As Int32) As Boolean
Me.value = seed
Return Me.bool
End Function
End Structure
```

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.