Skip to content

fix: Fix a potential bug in ds.cc. - #276

Merged
hzhangxyz merged 1 commit into
mainfrom
dev/better-generator
Mar 15, 2026
Merged

fix: Fix a potential bug in ds.cc.#276
hzhangxyz merged 1 commit into
mainfrom
dev/better-generator

Conversation

@hzhangxyz

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings March 15, 2026 09:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates language binding iterators (Python via pybind11 and TypeScript/JS via embind) to use the generator’s end sentinel when detecting exhaustion.

Changes:

  • Replace *iterator == nullptr with *iterator == generator.end() in Iterator::next() for both bindings.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
atsds/ds.cc Use generator.end() sentinel for JS/TS binding iterator exhaustion check.
apyds/ds.cc Use generator.end() sentinel for Python binding iterator exhaustion check.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread atsds/ds.cc
Comment on lines 13 to 21
ds::rule_t* next() {
if (initialized) {
++*iterator;
} else {
iterator = std::make_unique<iterator_t>(generator.begin());
initialized = true;
}
if (*iterator == nullptr) {
if (*iterator == generator.end()) {
return nullptr;
Comment thread apyds/ds.cc
Comment on lines 14 to 22
ds::rule_t* next() {
if (initialized) {
++*iterator;
} else {
iterator = std::make_unique<iterator_t>(generator.begin());
initialized = true;
}
if (*iterator == nullptr) {
if (*iterator == generator.end()) {
return nullptr;
@hzhangxyz
hzhangxyz merged commit b39df34 into main Mar 15, 2026
90 checks passed
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