google / google/xls

Type deduction for literals

Open
#640 0 comments 0 reactions 0 assignees View on GitHub
dslx enhancement
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

In DSLX, binary operation expressions with literals annotated with their type.

For example,
```
let i:u32 = u32:3;
let j:u32 = i + u32:2;
```

For readability, ideally, the above segment of code should read:
```
let i:u32 = 3;
let j:u32 = i + 2;
```

Note that the types for literal '3' and '2' can be inferred since the variable is annotated with a type.

For literals where the types can be inferred, as in the above example, would enable more readable code. For scenarios where the literal value does not fit in the inferred type. DSLX can output an error.

For example. the following should output an error.
```
let i:u3 = 1024;
```

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.