Throw a KernelError for non-singleton type arguments - #954
Merged
Merged
Conversation
Before `Core.TypeEgal`, `Type{T}` is only a singleton when `T` has a unique
representation, so an argument like `Type{Union{Missing, Bool}}` or `Type{Vector}`
fell through to `fieldcount`, which threw an unhelpful `ArgumentError`. Report it as a
`KernelError` suggesting `Val(T)` instead.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #954 +/- ##
=======================================
Coverage 86.41% 86.41%
=======================================
Files 29 29
Lines 5674 5676 +2
=======================================
+ Hits 4903 4905 +2
Misses 771 771 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Julia 1.13 and earlier,
Core.Compiler.isconstType(Type{T})is only true whenThas a unique representation. That excludes unions andUnionAlls, so a kernel argument likeType{Union{Missing, Bool}}orType{Vector}falls throughcheck_invocationtofieldcount, which throws:Such an argument can't work there anyway, because Julia's codegen passes it as a boxed host pointer. This PR reports it as a
KernelError:On Julia with
Core.TypeEgal(JuliaLang/julia#62001),methodinstancealready turns these intoTypeEgal{T}singletons, so the check never fires there. The test covers both cases.This came up in JuliaGPU/KernelAbstractions.jl#791, where the POCL back-end's
zeros(::POCLBackend, Union{Missing, Bool}, ...)passed the element type to a kernel. That is fixed on the KA side in JuliaGPU/KernelAbstractions.jl#795.