Skip to content

Commit 38e3514

Browse files
authored
Lower cglobal to GlobalRef(Core.Intrinsics, :cglobal) (#86)
Fix the lowering of `cglobal` to produce `GlobalRef(Core.Intrinsics, :cglobal)` instead of a bare symbol `:cglobal`. The inference validator requires cglobal to be a GlobalRef: https://github.com/JuliaLang/julia/blob/7a8cd6e202f1d1216a6c0c0b928fb43a123cada8/Compiler/src/validation.jl#L87 With this commit `_to_lowered_expr` resolves `cglobal` to `GlobalRef(Core.Intrinsics, :cglobal)`, matching Julia's builtin lowerer behavior and satisfying the inference validator's requirements.
1 parent e57d69c commit 38e3514

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/eval.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,10 @@ function _to_lowered_expr(ex::SyntaxTree, stmt_offset::Int)
331331
elseif k == K"core"
332332
name = ex.name_val
333333
if name == "cglobal"
334-
# cglobal isn't a true name within core - instead it's a builtin
335-
:cglobal
334+
# Inference expects cglobal as call argument to be `GlobalRef`,
335+
# so we resolve that name as a symbol of `Core.Intrinsics` here.
336+
# https://github.com/JuliaLang/julia/blob/7a8cd6e202f1d1216a6c0c0b928fb43a123cada8/Compiler/src/validation.jl#L87
337+
GlobalRef(Core.Intrinsics, :cglobal)
336338
elseif name == "nothing"
337339
# Translate Core.nothing into literal `nothing`s (flisp uses a
338340
# special form (null) for this during desugaring, etc)

0 commit comments

Comments
 (0)