Skip to content

Commit

Permalink
fix return types of auto generated fn calls for math fns
Browse files Browse the repository at this point in the history
Must return `auto` as it must be based on the return type of `fn(x)` call.
  • Loading branch information
Vindaar committed Nov 16, 2022
1 parent de003e1 commit 2c4696f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions measuremancer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,12 @@ proc `^`*[T: FloatLike](a, b: Measurement[T]): Measurement[T] = a ** b

import std / macros
template genCall(fn, letStmt, x, m, deriv: untyped): untyped =
proc `fn`*[T](m: Measurement[T]): Measurement[T] =
proc `fn`*[T](m: Measurement[T]): auto =
## letStmt contains the definition of x, `let x = m.val`
letStmt
## `deriv` is handed as an expression containing `x`
result = procRes(fn(x), deriv, m)
type U = typeof(fn(x))
result = procRes(fn(x), deriv, m.to(U))

macro defineSupportedFunctions(body: untyped): untyped =
result = newStmtList()
Expand Down

0 comments on commit 2c4696f

Please sign in to comment.