-
-
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
Overloaded template causes untyped
param is resolved when called.
#23662
Labels
Comments
litlighilit
changed the title
Overloaded template causes
Overloaded template causes May 30, 2024
untyped
param is resolved.untyped
param is resolved when called.
!nim c template t(n: float) = discard
template t(todecl: untyped, x: int) =
discard
t(ii, 3) |
🐧 Linux bisect by @juancarlospaco (collaborator)devel 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("n"),
newIdentNode("float"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("todecl"),
newIdentNode("untyped"),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("x"),
newIdentNode("int"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkCall.newTree(
newIdentNode("t"),
newIdentNode("ii"),
newLit(3)
)
) stable 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("n"),
newIdentNode("float"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("todecl"),
newIdentNode("untyped"),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("x"),
newIdentNode("int"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkCall.newTree(
newIdentNode("t"),
newIdentNode("ii"),
newLit(3)
)
) 2.0.4 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("n"),
newIdentNode("float"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("todecl"),
newIdentNode("untyped"),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("x"),
newIdentNode("int"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkCall.newTree(
newIdentNode("t"),
newIdentNode("ii"),
newLit(3)
)
) 2.0.0 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("n"),
newIdentNode("float"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("todecl"),
newIdentNode("untyped"),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("x"),
newIdentNode("int"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkCall.newTree(
newIdentNode("t"),
newIdentNode("ii"),
newLit(3)
)
) 1.6.20 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("n"),
newIdentNode("float"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("todecl"),
newIdentNode("untyped"),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("x"),
newIdentNode("int"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkCall.newTree(
newIdentNode("t"),
newIdentNode("ii"),
newLit(3)
)
) 1.4.8 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("n"),
newIdentNode("float"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("todecl"),
newIdentNode("untyped"),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("x"),
newIdentNode("int"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkCall.newTree(
newIdentNode("t"),
newIdentNode("ii"),
newLit(3)
)
) 1.2.18 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("n"),
newIdentNode("float"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("todecl"),
newIdentNode("untyped"),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("x"),
newIdentNode("int"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkCall.newTree(
newIdentNode("t"),
newIdentNode("ii"),
newLit(3)
)
) 1.0.10 👎 FAILOutput
IRCompiled filesize0 bytes (0 bytes)
Stats
ASTnnkStmtList.newTree(
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("n"),
newIdentNode("float"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkTemplateDef.newTree(
newIdentNode("t"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode(),
nnkIdentDefs.newTree(
newIdentNode("todecl"),
newIdentNode("untyped"),
newEmptyNode()
),
nnkIdentDefs.newTree(
newIdentNode("x"),
newIdentNode("int"),
newEmptyNode()
)
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
nnkDiscardStmt.newTree(
newEmptyNode()
)
)
),
nnkCall.newTree(
newIdentNode("t"),
newIdentNode("ii"),
newLit(3)
)
) Stats
🤖 Bug found in |
Same behaviour from 1.0 to devel. 🤷 |
This is required for dispatch, overloaded macros and templates have to semantically check arguments for a call in cases of ambiguity. |
Another workaround: make the overloaded templates' param untyped, too. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
If a template with untyped params is overloaded, then when the variant with
untyped
param is called, such a argument (symbol) will be resolved there.In addition, either of the followings compiles without mistake:
Or
Nim Version
Nim Compiler Version 2.1.1 [Windows: amd64]
Compiled at 2024-04-27
Copyright (c) 2006-2024 by Andreas Rumpf
active boot switches: -d:release
Current Output
Expected Output
Possible Solution
No response
Additional Information
So does for
macro
,proc
, etc.The text was updated successfully, but these errors were encountered: