You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working with dynamic dispatch base methods, IDE integrations which use nimsuggest and/or nimsuggest via the CLI trigger an error on the following code:
typeExpression=refobjectofRootObj## abstract base class for an expressionLiteral=refobjectofExpression
x: intPlusExpr=refobjectofExpression
a, b: Expression# watch out: 'eval' relies on dynamic bindingmethodeval(e: Expression): int {.base.} =# override this base methodquit"to override!"methodeval(e: Literal): int= e.x
methodeval(e: PlusExpr): int=eval(e.a) +eval(e.b)
procnewLit(x: int): Literal=Literal(x: x)
procnewPlus(a, b: Expression): PlusExpr=PlusExpr(a: a, b: b)
echoeval(newPlus(newPlus(newLit(1), newLit(2)), newLit(4)))
I had the same problem as OP, but I guess the problem is that I was using nimlsp, the author of which hasn't kept it up to date with the latest nimsuggest protocol updates (as far as I can tell, even V3 hasn't been implemented). So the answer was to switch to nimlangserver. After switching, the {.base.} error is gone.
So I can confirm if I run with explicit --v4 as above then yes it appears to work as expected.
So perhaps the error is instead within the handling by nimlangserver? However based upon what @Seanld said this worked for them.
For me running either vscode integration or neovim with nimlangserver still shows errors.
Description
When working with dynamic dispatch base methods, IDE integrations which use nimsuggest and/or nimsuggest via the CLI trigger an error on the following code:
This code is directly lifted from tutorial https://nim-lang.org/docs/tut2.html#object-oriented-programming-dynamic-dispatch
The error in question is
method is not a base
When running nimsuggest chk on this code it reports (path was changed for privacy reasons)
Nim Version
Nim Compiler Version 2.0.4 [Linux: amd64]
Compiled at 2024-03-28
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: b47747d
active boot switches: -d:release -d:danger --gc:markAndSweep
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
This manifested for me initially with the VSCode extension https://github.com/nim-lang/vscode-nim but own investigation appeared to be in nimsuggest
The text was updated successfully, but these errors were encountered: