Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action to check builtin consistency #541

Merged
merged 4 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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