Skip to content

Commit 4e5f85e

Browse files
authored
_register_kinds!: prevent unintentional closure capture, boxing (#586) (#589)
The variable `i` was unintentionally shared between the generator closure in `_register_kinds!` and another part of the body of `_register_kinds!`. Thus `i` was boxed, causing trouble for inference. Fix this by moving the part of `_register_kinds!` with `i` to a new function. Fixing this should make the sysimage more resistant to invalidation, once the change propagates to Julia itself. (cherry picked from commit 00bd17e)
1 parent dba9076 commit 4e5f85e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/kinds.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ function _register_kinds!(kind_modules, int_to_kindstr, kind_str_to_int, mod, mo
102102
error("Kind module ID $module_id already claimed by module $m")
103103
end
104104
end
105+
_register_kinds_names!(int_to_kindstr, kind_str_to_int, module_id, names)
106+
end
107+
108+
# This function is separated from `_register_kinds!` to prevent sharing of the variable `i`
109+
# here and in the closure in `_register_kinds!`, which causes boxing and bad inference.
110+
function _register_kinds_names!(int_to_kindstr, kind_str_to_int, module_id, names)
105111
# Process names to conflate category BEGIN/END markers with the first/last
106112
# in the category.
107113
i = 0

0 commit comments

Comments
 (0)