Skip to content

Commit 00e9062

Browse files
committed
Comment out unreachable code paths in type stability helpers
- Line 69: else branch in _stabilize_mesh_type (map(identity, mesh)) - Line 125: non-concrete mesh warning in first MeshArray constructor - Line 155: non-concrete mesh warning in second MeshArray constructor These branches are unreachable in practice because typeof() always returns the actual runtime type, which is concrete. The code is kept as commented out for defensive programming and documentation purposes. Reason: typeof(x) evaluates to the runtime type, not the compile-time inferred type, so isconcretetype(typeof(x)) is always true.
1 parent 98c3a97 commit 00e9062

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/mesharrays/dense.jl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ function _stabilize_mesh_type(mesh::Tuple)
6464
# Concretize the mesh tuple type
6565
if isconcretetype(typeof(mesh))
6666
return mesh
67-
else
67+
# else
68+
# NOTE: This branch is unreachable in practice because typeof() always returns
69+
# the actual runtime type, which is concrete. Kept for defensive programming.
6870
# Create a new tuple while preserving the type of each element
69-
return map(identity, mesh)
71+
# return map(identity, mesh)
7072
end
7173
end
7274

@@ -121,9 +123,11 @@ function MeshArray(mesh...;
121123

122124
mesh = _stabilize_mesh_type(mesh)
123125

124-
if isconcretetype(typeof(mesh)) == false
125-
@warn "Mesh type $(typeof(mesh)) is not concrete, it may cause performance issue."
126-
end
126+
# NOTE: This check is unreachable in practice because typeof() always returns
127+
# the actual runtime type, which is concrete. Kept for defensive programming.
128+
# if isconcretetype(typeof(mesh)) == false
129+
# @warn "Mesh type $(typeof(mesh)) is not concrete, it may cause performance issue."
130+
# end
127131

128132
N = length(mesh)
129133
dims = tuple([length(v) for v in mesh]...)
@@ -151,9 +155,11 @@ function MeshArray(; mesh::Union{Tuple,AbstractVector},
151155

152156
mesh = _stabilize_mesh_type(mesh)
153157

154-
if isconcretetype(typeof(mesh)) == false
155-
@warn "Mesh type $(typeof(mesh)) is not concrete, it may cause performance issue."
156-
end
158+
# NOTE: This check is unreachable in practice because typeof() always returns
159+
# the actual runtime type, which is concrete. Kept for defensive programming.
160+
# if isconcretetype(typeof(mesh)) == false
161+
# @warn "Mesh type $(typeof(mesh)) is not concrete, it may cause performance issue."
162+
# end
157163

158164
@assert mesh isa Tuple "mesh should be a tuple, now get $(typeof(mesh))"
159165
N = length(mesh)

0 commit comments

Comments
 (0)