Skip to content

Commit

Permalink
Merge pull request #541 from JuliaDebug/sp/check-builtins-consistency
Browse files Browse the repository at this point in the history
Add action to check builtin consistency
  • Loading branch information
pfitzseb authored Jul 25, 2022
2 parents fd31ef3 + cbf40fe commit 20e5204
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/check_builtins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI
on:
pull_request:
push:
branches:
- master
tags: '*'
jobs:
test:
name: 'Check builtins.jl consistency'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: nightly
arch: x64
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- run: julia test/check_builtins.jl
1 change: 1 addition & 0 deletions bin/generate_builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const RECENTLY_ADDED = Core.Builtin[
Core.get_binding_type, Core.set_binding_type!,
Core.getglobal, Core.setglobal!,
Core.modifyfield!, Core.replacefield!, Core.swapfield!,
Core.finalizer
]
const kwinvoke = Core.kwfunc(Core.invoke)

Expand Down
10 changes: 10 additions & 0 deletions src/builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
return Some{Any}(Core.const_arrayref(getargs(args, frame)...))
elseif @static isdefined(Core, :donotdelete) && f === Core.donotdelete
return Some{Any}(Core.donotdelete(getargs(args, frame)...))
elseif @static isdefined(Core, :finalizer) && f === Core.finalizer
if nargs == 2
return Some{Any}(Core.finalizer(@lookup(frame, args[2]), @lookup(frame, args[3])))
elseif nargs == 3
return Some{Any}(Core.finalizer(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
elseif nargs == 4
return Some{Any}(Core.finalizer(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
else
return Some{Any}(Core.finalizer(getargs(args, frame)...))
end
elseif @static isdefined(Core, :get_binding_type) && f === Core.get_binding_type
if nargs == 2
return Some{Any}(Core.get_binding_type(@lookup(frame, args[2]), @lookup(frame, args[3])))
Expand Down
12 changes: 12 additions & 0 deletions test/check_builtins.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Test

@static if VERSION >= v"1.9.0-"
@testset "Check builtin.jl consistency" begin
builtins_path = joinpath(@__DIR__, "..", "src", "builtins.jl")
old_builtins = read(builtins_path, String)
include("../bin/generate_builtins.jl")
new_builtins = read(builtins_path, String)
print(builtins_path, old_builtins)
@test old_builtins == new_builtins
end
end
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ using JuliaInterpreter
using Test
using Logging

include("check_builtins.jl")

@test isempty(detect_ambiguities(JuliaInterpreter, Base, Core))

if !isdefined(@__MODULE__, :read_and_parse)
Expand Down

0 comments on commit 20e5204

Please sign in to comment.