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

fixes #11225; generic sandwich problems; [backport:1.2] #17255

Merged
merged 4 commits into from
Mar 9, 2021
Merged

Conversation

Araq
Copy link
Member

@Araq Araq commented Mar 4, 2021

No description provided.

doc/manual.rst Outdated
@@ -5118,6 +5118,50 @@ scope is the default.
``bind`` statements only make sense in templates and generics.


Delegating mixin statements
Copy link
Member

@timotheecour timotheecour Mar 4, 2021

Choose a reason for hiding this comment

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

@@ -860,7 +860,7 @@ proc containsResult(n: PNode): bool =
for i in 0..<n.safeLen:
if containsResult(n[i]): return true

const harmless = {nkConstSection, nkTypeSection, nkEmpty, nkCommentStmt, nkTemplateDef, nkMacroDef} +
const harmless = {nkConstSection, nkTypeSection, nkEmpty, nkCommentStmt, nkTemplateDef, nkMacroDef, nkMixinStmt} +
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't nkMixinStmt be stripped away in semantic pass before it reaches backend, eg, so that it doesn't affect each backend

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe, but I'm generally in favor of not losing information in the AST. As you can see there are always things that backends explicitly need to ignore anyway.

@Araq Araq added the TODO: followup needed remove tag once fixed or tracked elsewhere label Mar 9, 2021
@Araq
Copy link
Member Author

Araq commented Mar 9, 2021

Merging this for now as most changes are related to handle the nkMixinStmt, nkBindStmt in the backends which is worthwhile no matter what we end up with.

@Araq Araq merged commit 2f213db into devel Mar 9, 2021
@Araq Araq deleted the araq-sandwiches branch March 9, 2021 19:19
@mratsim
Copy link
Collaborator

mratsim commented Mar 9, 2021

So if I understand correctly the toSeq macro in sequtils should be patched to use bind items so that it stops being an annoyance with Hashsets, Tables, Intsets and all other collections?

@timotheecour
Copy link
Member

timotheecour commented Mar 9, 2021

# a.nim
iterator items(a: int): int = discard
proc p*(a: int | uint) =
  # for _ in a.items: discard # ok
  bind items # doesn't help
  for _ in a: discard # still a bug

# b.nim
import a
p 1

still gives Error: type mismatch: got <int>

Regarding toSeq, I'm going to make the bold claim that iterable[T] from #17196 will fix all the problems with not just toSeq but many other issues related to called iterators being treated (currently) as untyped

narimiran pushed a commit that referenced this pull request Mar 18, 2021
* fixes #11225; generic sandwich problems; [backport:1.2]
* progress
* delegating these symbols must be done via 'bind'

(cherry picked from commit 2f213db)
narimiran pushed a commit that referenced this pull request Mar 18, 2021
* fixes #11225; generic sandwich problems; [backport:1.2]
* progress
* delegating these symbols must be done via 'bind'

(cherry picked from commit 2f213db)
narimiran pushed a commit that referenced this pull request Mar 18, 2021
* fixes #11225; generic sandwich problems; [backport:1.2]
* progress
* delegating these symbols must be done via 'bind'

(cherry picked from commit 2f213db)
narimiran pushed a commit that referenced this pull request Mar 20, 2021
* fixes #11225; generic sandwich problems; [backport:1.2]
* progress
* delegating these symbols must be done via 'bind'

(cherry picked from commit 2f213db)
ringabout pushed a commit to ringabout/Nim that referenced this pull request Mar 22, 2021
…lang#17255)

* fixes nim-lang#11225; generic sandwich problems; [backport:1.2]
* progress
* delegating these symbols must be done via 'bind'
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
…lang#17255)

* fixes nim-lang#11225; generic sandwich problems; [backport:1.2]
* progress
* delegating these symbols must be done via 'bind'
narimiran added a commit that referenced this pull request Apr 13, 2021
@timotheecour
Copy link
Member

potential root cause for #17704 regression

narimiran pushed a commit that referenced this pull request Dec 7, 2021
* fixes #11225; generic sandwich problems; [backport:1.2]
* progress
* delegating these symbols must be done via 'bind'

(cherry picked from commit 2f213db)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TODO: followup needed remove tag once fixed or tracked elsewhere
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants