Created
February 24, 2026 17:09
-
-
Save Keno/119228850174da4ea724f2aaca64d235 to your computer and use it in GitHub Desktop.
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
| # gc_preserve: SSA for gc_preserve_begin token spans user body | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _gc_pres_goto() | |
| x = [1,2,3] | |
| @goto foo | |
| GC.@preserve x begin | |
| @label foo | |
| length(x) | |
| end | |
| end | |
| end) | |
| # setproperty!: SSA for complex base spans rhs | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _setprop_goto() | |
| @goto foo | |
| Ref(0).x = (begin; @label foo; 42; end) | |
| end | |
| end) | |
| # getindex: call-arg SSA for complex base spans index containing label | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _getidx_goto() | |
| v = [10,20,30] | |
| @goto foo | |
| identity(v)[let; @label foo; 2; end] | |
| end | |
| end) | |
| # kwcall: SSA for complex callee spans kw args | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _kwcall_goto() | |
| mykw(x; digits=0) = round(x; digits) | |
| @goto foo | |
| identity(mykw)(3.14; digits=(begin; @label foo; 2; end)) | |
| end | |
| end) | |
| # chained comparison: comparison operator SSA defined in conditional branch | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _cmp_goto() | |
| @goto foo | |
| 1 < 2 < (begin; @label foo; 3; end) | |
| end | |
| end) | |
| # chained comparison with complex middle operand | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _cmp_goto2() | |
| @goto foo | |
| 1 < identity(2) < (begin; @label foo; 3; end) | |
| end | |
| end) | |
| # ccall multi-arg: first arg's cconvert SSA spans later arg with label | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _ccall_multi_goto() | |
| buf1 = Vector{UInt8}(undef, 10) | |
| buf2 = Vector{UInt8}(undef, 10) | |
| @goto foo | |
| ccall(:memcpy, Ptr{Cvoid}, (Ptr{UInt8}, Ptr{UInt8}, Csize_t), | |
| buf1, (begin; @label foo; buf2; end), 0) | |
| end | |
| end) | |
| # update .=: SSA for complex lhs spans rhs | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _dotupd_goto() | |
| v = [1,2,3] | |
| @goto foo | |
| identity(v) .+= (begin; @label foo; [10,20,30]; end) | |
| end | |
| end) | |
| # setindex! with end: SSA for base array (needed for end) spans rhs | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _setidx_end_goto() | |
| v = [10, 20, 30] | |
| @goto foo | |
| identity(v)[end] = (begin; @label foo; 99; end) | |
| end | |
| end) | |
| # dot-operator chained comparison: look-ahead SSA for eager evaluation | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _dotcmp_goto() | |
| @goto foo | |
| 1 < 2 .< 3 .< (begin; @label foo; 4; end) | |
| end | |
| end) | |
| # splatted complex index: SSA for splatted arg spans later index | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _splat_idx_goto() | |
| v = zeros(2,3) | |
| @goto foo | |
| v[identity((1,))..., ((@label foo); 1)] | |
| end | |
| end) | |
| # tuple-tuple destructuring: earlier element SSA spans later element | |
| @test Expr(:error, err) == | |
| Meta.lower(@__MODULE__, quote | |
| function _tuplpair_goto() | |
| @goto foo | |
| (a, b) = (identity(1), (begin; @label foo; 2; end)) | |
| (a, b) | |
| end | |
| end) | |
| end # let err |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment