Skip to content

Commit 08b9a80

Browse files
AstitvaAggarwalyebaisunxd3
authored
_copy_to_output!! error handling for mismatched types (#858)
* _copy_to_output!! error handling for mismatched types * update project.toml * comments * Improve error handling in _copy_to_output!! function Enhance error message in _copy_to_output!! function to provide more context about type mismatch. Signed-off-by: Hong Ge <[email protected]> * format. * Apply suggestions from code review Co-authored-by: Xianda Sun <[email protected]> Signed-off-by: Hong Ge <[email protected]> * minor tweaks --------- Signed-off-by: Hong Ge <[email protected]> Co-authored-by: Hong Ge <[email protected]> Co-authored-by: Hong Ge <[email protected]> Co-authored-by: Xianda Sun <[email protected]>
1 parent 01f7053 commit 08b9a80

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Mooncake"
22
uuid = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
33
authors = ["Will Tebbutt, Hong Ge, and contributors"]
4-
version = "0.4.177"
4+
version = "0.4.178"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/interface.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,19 @@ function _copy_to_output!!(dst::P, src::P) where {P}
317317
end
318318
end
319319

320+
# fallback for invalid type combinations
321+
function _copy_to_output!!(dst::T, src::P) where {T,P}
322+
throw(
323+
ArgumentError(
324+
"Mooncake.jl does not currently have a method " *
325+
"`_copy_to_output!!` to handle this type combination: " *
326+
"dst passed is of type $T, while src is a $P. " *
327+
"This often happens when differentiating over " *
328+
"non-differentiable types (e.g. integers or booleans).",
329+
),
330+
)
331+
end
332+
320333
"""
321334
_copy_output(x::T)
322335

0 commit comments

Comments
 (0)