Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty list bug #1358

Merged
merged 1 commit into from
Mar 8, 2023
Merged

Fix empty list bug #1358

merged 1 commit into from
Mar 8, 2023

Conversation

acquamarin
Copy link
Collaborator

This PR fixes empty list bug.

@@ -281,8 +281,11 @@ std::string Value::toString() const {
std::string result = "[";
for (auto i = 0u; i < listVal.size(); ++i) {
result += listVal[i]->toString();
result += (i == listVal.size() - 1 ? "]" : ",");
if (i != listVal.size() - 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually prefer for i =0, I < size - 1 and write an additional line after the loop which avoids unnecessary runtime if checking. But up to u.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the listVal.size() is 0, i think this code: for i =0, I < size - 1 will cause a bug.

@acquamarin acquamarin merged commit ddaa2fa into master Mar 8, 2023
@acquamarin acquamarin deleted the fix-empty-list branch March 8, 2023 04:10
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.

2 participants