google / google/xls

Types should be optionally emitted with trace_fmt

Open
#888 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

Currently (or very soon when some in progress change lands), trace_fmt emits untyped literal values:

```
trace_fmt!("myvalue = {:#x}", myvalue)
// myvalue = 0xbeef
````

It'd be nice to have a way of emitting the type as well, maybe via an additional character in the format string:

```
trace_fmt("myvalue = {:#xt}, my value)
// myvalue = u42:0xbeef
```

This has the advantage of making the values parsable which is nice for cut and pasting large data structures emitted via trace_fmt into test code. Also, printing the types (of course) reveals to the user what the types actually are which is not always obvious.

Also, it'd be super cool if you could actually emit the type alias:

```
trace_fmt("myvalue = {:#xt}, my value)
// myvalue = MyModule::MyType:0xbeef
```

and perhaps a mode which gives you the type alias and the underlying type:

```
trace_fmt("myvalue = {:#xT}, my value)
// myvalue = MyModule::MyType:0xbeef (u42)
```

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.