Skip to content

Commit 26e38cc

Browse files
authored
fix fields description of Module type (#37645)
The fields are not accessible, so it is awkward to report they exist. Fixes #37630 Caused issues starting with #34804
1 parent 5f55b97 commit 26e38cc

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

base/boot.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#abstract type Vararg{T} end
99

1010
#mutable struct Symbol
11-
# #opaque
11+
## opaque
1212
#end
1313

1414
#mutable struct TypeName
@@ -53,28 +53,43 @@
5353
#abstract type DenseArray{T,N} <: AbstractArray{T,N} end
5454

5555
#mutable struct Array{T,N} <: DenseArray{T,N}
56+
## opaque
5657
#end
5758

5859
#mutable struct Module
59-
# name::Symbol
60+
## opaque
61+
#end
62+
63+
#mutable struct SimpleVector
64+
## opaque
65+
#end
66+
67+
#mutable struct String
68+
## opaque
6069
#end
6170

6271
#mutable struct Method
72+
#...
6373
#end
6474

6575
#mutable struct MethodInstance
76+
#...
6677
#end
6778

6879
#mutable struct CodeInstance
80+
#...
6981
#end
7082

7183
#mutable struct CodeInfo
84+
#...
7285
#end
7386

7487
#mutable struct TypeMapLevel
88+
#...
7589
#end
7690

7791
#mutable struct TypeMapEntry
92+
#...
7893
#end
7994

8095
#abstract type Ref{T} end

base/compiler/tfuncs.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -951,11 +951,11 @@ function fieldtype_tfunc(@nospecialize(s0), @nospecialize(name))
951951
if s0 === Any || s0 === Type || DataType s0 || UnionAll s0
952952
return Type
953953
end
954-
# fieldtype only accepts Types, errors on `Module`
955-
if isa(s0, Const) && (!(isa(s0.val, DataType) || isa(s0.val, UnionAll) || isa(s0.val, Union)) || s0.val === Module)
954+
# fieldtype only accepts Types
955+
if isa(s0, Const) && !(isa(s0.val, DataType) || isa(s0.val, UnionAll) || isa(s0.val, Union))
956956
return Bottom
957957
end
958-
if (s0 isa Type && (s0 == Type{Module} || s0 == Type{Union{}})) || isa(s0, Conditional)
958+
if (s0 isa Type && s0 == Type{Union{}}) || isa(s0, Conditional)
959959
return Bottom
960960
end
961961

src/datatype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ void jl_compute_field_offsets(jl_datatype_t *st)
379379
st->layout = &opaque_byte_layout;
380380
return;
381381
}
382-
else if (st == jl_simplevector_type || st->name == jl_array_typename) {
382+
else if (st == jl_simplevector_type || st == jl_module_type || st->name == jl_array_typename) {
383383
static const jl_datatype_layout_t opaque_ptr_layout = {0, 1, -1, sizeof(void*), 0, 0};
384384
st->layout = &opaque_ptr_layout;
385385
return;

src/jltypes.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,8 +2170,9 @@ void jl_init_types(void) JL_GC_DISABLED
21702170

21712171
jl_module_type =
21722172
jl_new_datatype(jl_symbol("Module"), core, jl_any_type, jl_emptysvec,
2173-
jl_perm_symsvec(2, "name", "parent"),
2174-
jl_svec(2, jl_symbol_type, jl_any_type), 0, 1, 2);
2173+
jl_emptysvec, jl_emptysvec, 0, 1, 0);
2174+
jl_module_type->instance = NULL;
2175+
jl_compute_field_offsets(jl_module_type);
21752176

21762177
jl_value_t *symornothing[2] = { (jl_value_t*)jl_symbol_type, (jl_value_t*)jl_void_type };
21772178
jl_linenumbernode_type =

test/misc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ end
840840
end
841841

842842
@testset "fieldtypes Module" begin
843-
@test fieldtypes(Module) isa Tuple
843+
@test fieldtypes(Module) === ()
844844
end
845845

846846

0 commit comments

Comments
 (0)