Repository navigation
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:
|
maleadt
added a commit
that referenced
this pull request
Oct 7, 2026
* Use identity comparison during type mangling (#910) (cherry picked from commit 1c5bef9) * Mangle a `Vararg` whose length is still a `TypeVar` (#921) (cherry picked from commit 370be42) * Throw a KernelError for non-singleton type arguments (#954) (cherry picked from commit 87076e0) * Look up the global logger's level in the latest world (#977) (cherry picked from commit c2f106b) * PTX: Restore FMA contraction. (#881) (cherry picked from commit 96fb6f6) * [SPIRV] add workaround for khronos translator (#879) Co-authored-by: Tim Besard <tim.besard@gmail.com> (cherry picked from commit 081c892) * Handle allocation failure when boxing (#919) (cherry picked from commit ea53814) * Fix invalid IR from small type tags on Julia 1.10 and 1.11 (#972) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit b0dd255) * SPIR-V: lower llvm.minimum and llvm.maximum (#937) (cherry picked from commit 8eecfc8) * Metal: lower `llvm.sin` and `llvm.cos` to AIR (#967) Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> (cherry picked from commit cc26075) * Metal: lower bare LLVM fences to air.atomic.fence (#932) (cherry picked from commit cae55dd) * Metal: expand `llvm.powi` into multiplies (#946) [1.x: re-expressed in 1.23's worklist style, without #941's helpers.] Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> (cherry picked from commit 0d06ee4) * Metal: expand vector reductions into scalar chains (#962) [1.x: re-expressed in 1.23's worklist style, without #941's helpers.] Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> (cherry picked from commit 9f0d0b8) --------- Co-authored-by: Joachim Brand <j.brand@massey.ac.nz> Co-authored-by: Valentin Churavy <v.churavy@gmail.com> Co-authored-by: Simeon David Schaub <simeon@schaub.rocks> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Tim Esselens <tim.esselens@gmail.com>
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.