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
Sorry for the long repro code, it's quite tricky to extract it from my codebase and keep the issue reproducible as 3 differents procs/statements need to be present
This is a follow-up on my Go playing bot project which triggered many bugs last April every time I tried to avoid one:
cannot_infer.nim(90, 15) template/generic instantiation of `search_best_move` from here
cannot_infer.nim(81, 7) template/generic instantiation of `run_rollout` from here
cannot_infer.nim(19, 42) Error: cannot infer the value of the static param 'N'
import hashes, tables
type################################ Coordinates ###################################GoInt*=int32Point*[N: static[GoInt]] =distinctrange[-1.GoInt.. (N+2) * (N+2) -1]
# Can't use plain static[GoInt]: https://github.com/nim-lang/Nim/issues/7609################################ Coordinates ################################################################### Color & Moves ###################################Intersection*=enumEmpty, Black, White, Border################################ Board ###################################Board*[N: static[GoInt]] =array[(N+2) * (N+2), Intersection]
BoardState*[N: static[GoInt]] =refobject
board*: Board[N]
################################ Monte-Carlo ###################################Zobrist*=HashNode*[N: static[GoInt]] =objectNodeTable*[N: static[GoInt]] =Table[Zobrist, Node[N]]
MCTS_Context*[N: static[GoInt]] =object
nodes*: NodeTable[N]
################################ Procedures ###################################funcnewBoardState*(size: static[GoInt]): BoardState[size] =newresult# Remove for no crashfunc`$`*[N: static[GoInt]](board: Board[N]): string=# Display a go board - Triggers crash <------------------------------result="foo"procrun_rollout[N: static[GoInt]](
self: var MCTS_Context[N],
board_state: BoardState[N]) =var
amaf_color_map: array[(N+2)*(N+2), Intersection]
# Comment the following out and the project compiles:echo amaf_color_map # Triggers crash <------------------------------procsearch_best_move*[N: static[GoInt]](
self: var MCTS_Context[N], board_state: BoardState[N],
nb_simulations: Natural): Point[N] =
self.run_rollout(board_state)
################################ Bug ###################################var a =newBoardState(GoInt19) # Triggers crash <------------------------------# var a: BoardState[GoInt 19] # This is another possible fixvar ctx: MCTS_Context[GoInt19]
let move = ctx.search_best_move(a, 10)
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. If you think it is still a valid issue, write a comment below; otherwise it will be closed. Thank you for your contributions.
stalebot
added
the
stale
Staled PR/issues; remove the label after fixing them
label
Aug 4, 2020
Error: type mismatch: got <array[0..440, Intersection]>
but expected one of:
proc echo(x: varargs[typed, `$`])
first type mismatch at position: 1
required type for x: varargs[typed]
but expression 'amaf_color_map' is of type: array[0..440, Intersection]
stalebot
removed
the
stale
Staled PR/issues; remove the label after fixing them
label
Jan 20, 2021
Sorry for the long repro code, it's quite tricky to extract it from my codebase and keep the issue reproducible as 3 differents procs/statements need to be present
This is a follow-up on my Go playing bot project which triggered many bugs last April every time I tried to avoid one:
$
string conversion not matching #7611 (Static[non-int] +$
string conversion not matching)strformat
doesn't work properly inside generics #7632 (strformat
doesn't work properly inside generics and templates)With this new example I get:
The text was updated successfully, but these errors were encountered: