google / google/xls

DSLX is different from Rust for match patterns (currently does equality comparison for any bound identifier)

Open
#1,909 14 comments 0 reactions 1 assignee Claimed by @cdleary View on GitHub
dslx
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

The motivation is the following (incorrect) use of match:

```
fn f(x:bool, y:bool, z:bool) -> u32 {
match true {
x => u32:42,
y => u32:43,
z => u32:44,
_ => u32:45
}
}
```

Superficially this looks like it tests whether arguments x, y, or z are true and return a respective value. However, this construct creates a new temporary named `x` and binds true to it and returns 42.

This should raise a warning that the match temporaries `x`, `y`, and `z` are unused.

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.