Skip to content

Commit cc09911

Browse files
vtjnashNHDaly
authored andcommitted
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 3b82457 commit cc09911

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
@@ -925,11 +925,11 @@ function fieldtype_tfunc(@nospecialize(s0), @nospecialize(name))
925925
if s0 === Any || s0 === Type || DataType s0 || UnionAll s0
926926
return Type
927927
end
928-
# fieldtype only accepts Types, errors on `Module`
929-
if isa(s0, Const) && (!(isa(s0.val, DataType) || isa(s0.val, UnionAll) || isa(s0.val, Union)) || s0.val === Module)
928+
# fieldtype only accepts Types
929+
if isa(s0, Const) && !(isa(s0.val, DataType) || isa(s0.val, UnionAll) || isa(s0.val, Union))
930930
return Bottom
931931
end
932-
if s0 == Type{Module} || s0 == Type{Union{}} || isa(s0, Conditional)
932+
if s0 == Type{Union{}} || isa(s0, Conditional)
933933
return Bottom
934934
end
935935

src/datatype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ void jl_compute_field_offsets(jl_datatype_t *st)
359359
st->layout = &opaque_byte_layout;
360360
return;
361361
}
362-
else if (st == jl_simplevector_type || st->name == jl_array_typename) {
362+
else if (st == jl_simplevector_type || st == jl_module_type || st->name == jl_array_typename) {
363363
static const jl_datatype_layout_t opaque_ptr_layout = {0, 1, -1, sizeof(void*), 0, 0};
364364
st->layout = &opaque_ptr_layout;
365365
return;

src/jltypes.c

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

20162016
jl_module_type =
20172017
jl_new_datatype(jl_symbol("Module"), core, jl_any_type, jl_emptysvec,
2018-
jl_perm_symsvec(2, "name", "parent"),
2019-
jl_svec(2, jl_symbol_type, jl_any_type), 0, 1, 2);
2018+
jl_emptysvec, jl_emptysvec, 0, 1, 0);
2019+
jl_module_type->instance = NULL;
2020+
jl_compute_field_offsets(jl_module_type);
20202021

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

test/misc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,5 +860,5 @@ end
860860
end
861861

862862
@testset "fieldtypes Module" begin
863-
@test fieldtypes(Module) isa Tuple
863+
@test fieldtypes(Module) === ()
864864
end

0 commit comments

Comments
 (0)