Skip to content

Commit

Permalink
Include the procedure name that is missing in the error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
beef331 committed May 15, 2024
1 parent ce397c6 commit a5224b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/test.nim
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ suite "Basic":
check not compiles(10.toTrait DuckObject)
check errorCheck[PartiallyImplemented](BoundObject) == """
'PartiallyImplemented' failed to match 'BoundObject' due to missing the following procedure(s):
proc (a: Atom): int {.nimcall.}"""
doOtherThing: proc (a: Atom): int {.nimcall.}"""

check errorCheck[int](DuckObject) == """
'int' failed to match 'DuckObject' due to missing the following procedure(s):
proc (a: var Atom) {.nimcall.}"""
quack: proc (a: var Atom) {.nimcall.}"""
8 changes: 4 additions & 4 deletions traitor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ macro emitPointerProc(trait, instType: typed, err: static bool = false): untyped
implRet = ident"void"

result.add:
genast(prc, defRetType, implRet, typ = def[^2]):
genast(prc, defRetType, implRet, errorMsg = def.repr):
when not compiles(prc) or (defRetType isnot void and compiles((let x: defRetType = implRet))):
astToStr(typ)
errorMsg
else:
""
else:
Expand All @@ -258,9 +258,9 @@ macro emitPointerProc(trait, instType: typed, err: static bool = false): untyped
implRet = ident"void"

result.add:
genast(genProc, prc, defRetType):
genast(genProc, prc, defRetType, name = newLit def[0].repr):
when not compiles(genProc) or not returnTypeMatches(genProc, defRetType):
astToStr(prc)
name & ": " & astToStr(prc)
else:
""
else:
Expand Down
2 changes: 1 addition & 1 deletion traitor.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.2.13"
version = "0.2.14"
author = "Jason Beetham"
description = "Trait-like package made without insight"
license = "MIT"
Expand Down

0 comments on commit a5224b9

Please sign in to comment.