exaloop / exaloop/codon

Bug: Optional[Union] does not bind values as would be expected

Open
#747 3 comments 0 reactions 1 assignee Claimed by @inumanag View on GitHub
Dominant language
Python
Stars
16.8k
Forks
603
Avg merge
4d 23h
Merged PRs (30d)
6

Description

```
MyValueType = u64 | str

def func1(value: Optional[MyValueType] = None):
if value is None:
print("No value provided")
else:
print(f"Value provided: {value}")

func1("a")
```

Prints compilation error:
`optional_test.codon:15 (1-11): error: 'Optional[str]' does not match expected type 'Optional[Union[UInt[64] | str]]'`

Line 15 is the last line `func1("a")`

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.