-
-
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
fix #15959 #15979
fix #15959 #15979
Conversation
this doesn't
|
I have tried catch all |
Test failure is unrelated |
@@ -1513,6 +1513,9 @@ proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode = | |||
result = n | |||
else: | |||
result = nil | |||
of tyGenericParam: | |||
result = n | |||
result.typ = makeTypeFromExpr(c, n.copyTree) |
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.
That seems to be a bad idea, can't we add a better proc/syntax/interface to tyGenericParam
. The []
is very overloaded already, seems to be recipe for desaster.
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.
Not sure I understand. If []
was a proc defined in system then this change wouldn't be required, but nkBracketExpr is still the special beast that is handled by its own rules. These rules don't handle tyGenericParam
, hence the fix.
Another solution would be to define all missing procs in system.nim
proc `[]`[T: tuple](x: T, i: int): T {.magic: "XXX".}
Possibly others and then remove most of semSubscript
and rely on operator overloading.
Not sure this change will be easy and go smoothly though.
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.
[]
special rules indeed cause a lot of issues (eg #15911) and should be replaced by proper overloading (of possibly magic procs)
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
Please review the approach. My knowledge of generics is still lacking.
I have added
typeFromExpr
for subscript operator, but I was getting cannot Eval error from the vm inreplaceTypeVarsTAux
.Because of this I have patched
replaceTypeVarsTAux
to callsemExpr
instead ofsemConstExpr
and usesemConstExpr
only if needed. This step I am not sure about.