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

Make seq immutable in it's own iterator scope #18630

Open
Stuffe opened this issue Aug 2, 2021 · 1 comment
Open

Make seq immutable in it's own iterator scope #18630

Stuffe opened this issue Aug 2, 2021 · 1 comment

Comments

@Stuffe
Copy link

Stuffe commented Aug 2, 2021

Summary

Make seqs immutable in their own iterator scope.

Description

Right now calling for example .add() on a seq inside its own iterator scope will always result in a run time error. It is as sure to crash as assert(false). Yet sometimes this can go unnoticed in a branch. And right now, fixing this can be cumbersome since the error message also does not contain the line number.

Here is an example:
https://play.nim-lang.org/#ix=3uLg

Note that the index and value iterated over are already immutable inside an iterator scope, but what I ask is for the seq variable itself to also be immutable.

@Araq
Copy link
Member

Araq commented Aug 11, 2021

Seems to be handled well once we enable more borrow checking...

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

No branches or pull requests

2 participants