Skip to content

Commit

Permalink
Improve the error message when trying to assign to a slice of an immu…
Browse files Browse the repository at this point in the history
…table tensor (#611)

Before this change the compilation errors you'd get when trying to assign to an immutable tensor were very cryptic (a type mismatch, and you had to notice that the only tensor related option had a "var Tensor" type). This change results in a much more understandable and explicit error.
  • Loading branch information
AngelEzquerra authored Oct 26, 2023
1 parent 2fa5040 commit 12610a3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/arraymancer/tensor/accessors_macros_write.nim
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ macro `[]=`*[T](t: var Tensor[T], args: varargs[untyped]): untyped =
#
# result = quote do:
# slice_typed_dispatch_var(`t`, `new_args`)

template `[]=`*[T](t: Tensor[T], args: varargs[untyped]): untyped =
{.error: "a slice of an immutable tensor cannot be assigned to".}

0 comments on commit 12610a3

Please sign in to comment.