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

support type annotations on global variables #43671

Merged
merged 39 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f819538
add typing to global bindings
miguelraz Dec 17, 2021
ee478df
support type annotations on global variables
simeonschaub Dec 30, 2021
2846e34
rename to `_set_binding_type!`
simeonschaub Jan 5, 2022
b6e4587
try to fix analyzegc failure
simeonschaub Jan 5, 2022
a3e6c98
always add conversion step for globals
simeonschaub Jan 6, 2022
bc38f26
try to fix tests
simeonschaub Jan 6, 2022
1791c3c
fix inference test
simeonschaub Jan 6, 2022
c4161fd
fix analyzegc failures
simeonschaub Jan 7, 2022
28c8cba
allow `Core._get_binding_type` to be elided
simeonschaub Jan 8, 2022
646e2ab
clean up `julia-syntax.scm`
simeonschaub Jan 8, 2022
e0e0364
Merge remote-tracking branch 'origin/master' into sds/typedglobals
simeonschaub Jan 16, 2022
b28d542
add docs
simeonschaub Jan 16, 2022
b208fbf
add NEWS entry
simeonschaub Jan 16, 2022
d7e92f1
remove leading underscores in names
simeonschaub Jan 16, 2022
ff22fc0
fix docs
simeonschaub Jan 16, 2022
e93e694
just remove ref to `<:`
simeonschaub Jan 16, 2022
3656ddf
Merge remote-tracking branch 'origin/master' into sds/typedglobals
simeonschaub Jan 21, 2022
1d54432
try to make `ty` field atomic
simeonschaub Jan 22, 2022
ce66bbb
(de)serialize type field correctly
simeonschaub Jan 23, 2022
f2d1b48
Merge remote-tracking branch 'origin/master' into sds/typedglobals
simeonschaub Jan 23, 2022
931b7ba
fix serialization
simeonschaub Jan 24, 2022
e04c6be
address review comments
simeonschaub Jan 24, 2022
346220a
fix test, add test for different owner
simeonschaub Jan 24, 2022
8989e6e
try to fix distributed tests
simeonschaub Jan 24, 2022
de692a7
fix whitespace snafu
simeonschaub Jan 25, 2022
b36f3e2
Merge remote-tracking branch 'origin/master' into sds/typedglobals
simeonschaub Jan 25, 2022
edfadd3
refactor lowering a bit, fix unnecessary ssavalue
simeonschaub Jan 26, 2022
38d1b06
disallow type annotations in local scope
simeonschaub Feb 4, 2022
1504a97
Merge remote-tracking branch 'origin/master' into sds/typedglobals
simeonschaub Feb 4, 2022
160ee63
use nothing instead of NULL
simeonschaub Feb 4, 2022
a334a9b
address Jeff's review comment
simeonschaub Feb 7, 2022
efdb986
fix doctests
simeonschaub Feb 7, 2022
645f155
better error message in `head-to-text`
simeonschaub Feb 8, 2022
b442636
fix elision of `get_binding_type`
simeonschaub Feb 8, 2022
592c957
Merge remote-tracking branch 'origin/master' into sds/typedglobals
simeonschaub Feb 8, 2022
59bc7c0
fix tests
simeonschaub Feb 8, 2022
29afe48
update test for #33243
simeonschaub Feb 8, 2022
d265016
make test more robust
simeonschaub Feb 8, 2022
2183d33
use binding type in codegen?
simeonschaub Feb 8, 2022
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
Prev Previous commit
Next Next commit
rename to _set_binding_type!
  • Loading branch information
simeonschaub committed Jan 8, 2022
commit 2846e3408456e6a1ca56cacd98bf7cfac53caa26
2 changes: 1 addition & 1 deletion src/builtin_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ JL_CALLABLE(jl_f__abstracttype);
JL_CALLABLE(jl_f__primitivetype);
JL_CALLABLE(jl_f__setsuper);
JL_CALLABLE(jl_f__equiv_typedef);
JL_CALLABLE(jl_f__set_typeof);
JL_CALLABLE(jl_f__set_binding_type);

#ifdef __cplusplus
}
Expand Down
12 changes: 6 additions & 6 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1655,13 +1655,13 @@ JL_CALLABLE(jl_f__equiv_typedef)
return equiv_type(args[0], args[1]) ? jl_true : jl_false;
}

JL_CALLABLE(jl_f__set_typeof)
JL_CALLABLE(jl_f__set_binding_type)
{
JL_NARGS(_set_typeof!, 3, 3);
JL_TYPECHK(_set_typeof!, module, args[0]);
JL_TYPECHK(_set_typeof!, symbol, args[1]);
JL_NARGS(_set_binding_type!, 3, 3);
JL_TYPECHK(_set_binding_type!, module, args[0]);
JL_TYPECHK(_set_binding_type!, symbol, args[1]);
jl_value_t *ty = args[2];
JL_TYPECHK(_set_typeof!, type, ty);
JL_TYPECHK(_set_binding_type!, type, ty);
jl_binding_t *b = jl_get_binding_wr((jl_module_t*)args[0], (jl_sym_t*)args[1], 1);
if (b->constp && ty != (jl_value_t*)jl_any_type) {
simeonschaub marked this conversation as resolved.
Show resolved Hide resolved
jl_errorf("cannot set type for constant %s", jl_symbol_name(b->name));
Expand Down Expand Up @@ -1863,7 +1863,7 @@ void jl_init_primitives(void) JL_GC_DISABLED
add_builtin_func("_setsuper!", jl_f__setsuper);
jl_builtin__typebody = add_builtin_func("_typebody!", jl_f__typebody);
add_builtin_func("_equiv_typedef", jl_f__equiv_typedef);
add_builtin_func("_set_typeof!", jl_f__set_typeof);
add_builtin_func("_set_binding_type!", jl_f__set_binding_type);

// builtin types
add_builtin("Any", (jl_value_t*)jl_any_type);
Expand Down
2 changes: 1 addition & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4055,7 +4055,7 @@ f(x) = yt(x)
(put! globals ref rhs)
`(toplevel-butfirst
,(if temp `(block (= ,temp ,rhs0) (null)) '(null))
(call (core _set_typeof!) ,(cadr ref) (inert ,(caddr ref)) ,(caddr e))))
(call (core _set_binding_type!) ,(cadr ref) (inert ,(caddr ref)) ,(caddr e))))
`(call (core typeassert) ,@(cdr e))))
fname lam namemap defined toplevel interp opaq globals))))
;; `with-static-parameters` expressions can be removed now; used only by analyze-vars
Expand Down
2 changes: 1 addition & 1 deletion src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static const jl_fptr_args_t id_to_fptrs[] = {
&jl_f_arrayref, &jl_f_const_arrayref, &jl_f_arrayset, &jl_f_arraysize, &jl_f_apply_type,
&jl_f_applicable, &jl_f_invoke, &jl_f_sizeof, &jl_f__expr, &jl_f__typevar,
&jl_f_ifelse, &jl_f__structtype, &jl_f__abstracttype, &jl_f__primitivetype,
&jl_f__typebody, &jl_f__setsuper, &jl_f__equiv_typedef, &jl_f__set_typeof,
&jl_f__typebody, &jl_f__setsuper, &jl_f__equiv_typedef, &jl_f__set_binding_type,
&jl_f_opaque_closure_call,
NULL };

Expand Down