Skip to content

[TVMScript][Bugfix] Tuple on the RHS of AssignDoc#14452

Merged
junrushao merged 1 commit intoapache:unityfrom
junrushao:bugfix/2023-04-02/tuple-printing
Apr 2, 2023
Merged

[TVMScript][Bugfix] Tuple on the RHS of AssignDoc#14452
junrushao merged 1 commit intoapache:unityfrom
junrushao:bugfix/2023-04-02/tuple-printing

Conversation

@junrushao
Copy link
Copy Markdown
Member

This PR fixes a bug in TVMScript printer handling tuples on the RHS of an assignment, i.e.:

... = (a, b, c)
      ^^^^^^^^^

The existing sugar removes the brackets surrounding (a, b, c), which makes it slightly more readable as:

... = a, b, c

However, it overlooks a possibility where the tuple could be empty or has only one element, i.e.

... = (a, ) // Case 1: The tuple has only one element
... = ()    // Case 2: The tuple is empty

In both cases, removing brackets may lead to wrong outcome.

This patch fixes this bug.

@tvm-bot
Copy link
Copy Markdown
Collaborator

tvm-bot commented Apr 2, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@junrushao junrushao marked this pull request as ready for review April 2, 2023 22:17
This PR fixes a bug in TVMScript printer handling tuples on the RHS of
an assignment, i.e.:

```python
... = (a, b, c)
      ^^^^^^^^^
```

The existing  sugar removes the brackets surrounding `(a, b, c)`,
which makes it slightly more readable as:

```python
... = a, b, c
```

However, it overlooks a possibility where the tuple could be empty or
has only one element, i.e.

```python
... = (a, ) // Case 1: The tuple has only one element
... = ()    // Case 2: The tuple is empty
```

In both cases, removing brackets may lead to wrong outcome.

This patch fixes this bug.
@junrushao junrushao force-pushed the bugfix/2023-04-02/tuple-printing branch from 8356f83 to dd06ca7 Compare April 2, 2023 22:43
@junrushao junrushao merged commit 1527bfb into apache:unity Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants