-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support printing more types (#4071)
# Description ## Problem\* As part of our debugger implementation (see #3015) we need to extend the supported types that can be printed. We are using `noirc_printable_type` to keep values of variables at runtime for debug inspection. Also resolves #4073 ## Summary\* This PR adds support for converting these new types: - Tuples - Slices: lift the restriction to print them and handle arrays with dynamic size (flagging them with a `None` length in the type) - Functions: printed as an opaque `<<function>>` tag for now - Mutable references: printed as an opaque `<<mutable ref>>` tag for now - Unit: this is actually required to fully support function type conversion, for non-closured function references (ie. the environment is `()` in that case) The PR also fixes a preexisting bug when printing multiple values using formatted strings with the first ones being structs. Since structs are expanded into tuples which take up more than one field, the printing code would fail to skip over all the fields of the struct. ## Additional Context I've been using [this program](https://gist.github.com/ggiraldez/e3709def6c26e7585d12002fc8a0a216) to test this functionality. If it makes sense, I can add it as an integration test to `test_programs/execution_success`. The program produces this output: ``` (0x01, 0x02, 0x03) 0xbbbb # a = (0x01, 0x02, 0x03) # 0xeeee (0x01, 0x02, 0x03) == (0x01, 0x02, 0x03) ((0x01, 0x02, 0x03), 0x04, 0x05, 0x06) 0xbbbb # b = ((0x01, 0x02, 0x03), 0x04, 0x05, 0x06) # 0xeeee ((0x01, 0x02, 0x03), 0x04, 0x05, 0x06) == ((0x01, 0x02, 0x03), 0x04, 0x05, 0x06) <<mutable ref>> 0xbbbb # c = <<mutable ref>> # 0xeeee <<function>> 0xbbbb # d = <<function>> # 0xeeee <<function>> 0xbbbb # f = <<function>> # 0xeeee [0x01, 0x02, 0x03] 0xbbbb # g = [0x01, 0x02, 0x03] # 0xeeee [0x01, 0x02, 0x03] == [0x01, 0x02, 0x03] Foo { x: 555, y: 666 } == Foo { x: 555, y: 666 } Vec { slice: [0x01, 0x02] } 0xbbbb # h = Vec { slice: [0x01, 0x02] } # 0xeeee [0x01, 0x02] 0xbbbb # j = [0x01, 0x02] # 0xeeee [0x01, 0x02] == [0x01, 0x02] [printable_types] Circuit witness successfully solved ``` ## Documentation\* Check one: - [X] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [X] I have tested the changes locally. - [X] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: synthia <sy@nthia.dev>
- Loading branch information
Showing
4 changed files
with
104 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters