-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
.forbids pragma: defining forbidden tags #20050
Conversation
Excellent work. But we need to bikeshed about the name. "notTags"? How about "prevents"? "avoids"? "forbids"? |
Thank you! |
Meanwhile, I've added another test: tests/effects/teffects12.nim - this is the one I mentioned in the forum post. It's a simple code which enables safe locking for a resource while disabling recurrent locks. |
This patch intends to define the opposite of the .tags pragma: a way to define effects which are not allowed in a proc.
I've renamed the pragma to |
We also need a manual update, a changelog entry and an RFC. Maybe the RFC got already written though. And I don't say this to demotivate you, I'll help you push it through. We need to focus especially on the subtyping relation between |
Of course, I'll update the doc/manual.md and the changelog.md. I'll let you know when it's ready. I think this RFC is relevant: nim-lang/RFCs#302 |
the forbids pragma didn't handle simple restrictions properly and it also had issues with subtyping
While I was writing the documentation, I've found 2 bugs in the patch so I fixed them(and added 2 tests as coverage) before pushing this documentation/changelog update - let me know if you need anything added. |
The type relation must be documented and justified. |
Do you mean like this? |
wrong, per commend below |
I don't know why you keep phrasing it this way. Raises are additive too, except that |
my bad, got confused by some test code |
I've corrected the patch to properly support proc type subtyping and I've updated the manual too. |
doc/manual.md
Outdated
caller2(toBeCalled2) | ||
|
||
`ProcType2` is a subtype of `ProcType1`. Unlike with tags, the parent context | ||
doesn't inherit the forbidden list of effects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does that mean "the parent context doesn't inherit"? What is the "parent context"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say function1 calls function2 - then function1 is the "parent context". I'm calling it a context because it's a context of effects in terms of the effect system. I can't really articulate it, but I wanted to refer to a hierarchy of function calls and statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a little clarification to that line.
The CI is red because you need to update the docgen tests too. Please run:
|
Thanks! I updated the docs and pull from devel. |
It seems like I'm still missing something:
I tried |
Seems like the CI passed. Previously, I used |
Do we need anything else for the merge? |
Co-authored-by: ringabout <[email protected]>
Thanks for your hard work on this PR! Hint: mm: orc; threads: on; opt: speed; options: -d:release |
Thanks for the review and the merge! |
This is beautiful, thank you for implementing it! |
* .forbids pragma: defining illegal effects for proc types This patch intends to define the opposite of the .tags pragma: a way to define effects which are not allowed in a proc. * updated documentation and changelogs for the forbids pragma * renamed notTagEffects to forbiddenEffects * corrected issues of forbids pragma the forbids pragma didn't handle simple restrictions properly and it also had issues with subtyping * removed incorrect character from changelog * added test to cover the interaction of methods and the forbids pragma * covering the interaction of the tags and forbids pragmas * updated manual about the forbids pragma * removed useless statement * corrected the subtyping of proc types using the forbids pragma * updated manual for the forbids pragma * updated documentations for forbids pragma * updated nim docs * updated docs with rsttester.nim * regenerated documentation * updated rst docs * Update changelog.md Co-authored-by: ringabout <[email protected]> * updated changelog * corrected typo Co-authored-by: ringabout <[email protected]>
* .forbids pragma: defining illegal effects for proc types This patch intends to define the opposite of the .tags pragma: a way to define effects which are not allowed in a proc. * updated documentation and changelogs for the forbids pragma * renamed notTagEffects to forbiddenEffects * corrected issues of forbids pragma the forbids pragma didn't handle simple restrictions properly and it also had issues with subtyping * removed incorrect character from changelog * added test to cover the interaction of methods and the forbids pragma * covering the interaction of the tags and forbids pragmas * updated manual about the forbids pragma * removed useless statement * corrected the subtyping of proc types using the forbids pragma * updated manual for the forbids pragma * updated documentations for forbids pragma * updated nim docs * updated docs with rsttester.nim * regenerated documentation * updated rst docs * Update changelog.md Co-authored-by: ringabout <[email protected]> * updated changelog * corrected typo Co-authored-by: ringabout <[email protected]>
Hi,
I've made this to handle my use case we've discussed under this forum post. My tests are located at tests/effects/teffects1(1-7).nim. Let me know if you're willing to accept this PR and if anything needs to be done before merging. Thank you!