From f73f784cc05d8c184d9cbc1244ab6c1fdc0db681 Mon Sep 17 00:00:00 2001 From: aadityavardhan Date: Sun, 21 Aug 2022 07:57:59 +0530 Subject: [PATCH 1/4] Aadityavardhan Narayan: Progress toward support for static class attributes --- .gitignore | 6 ++ Cargo.lock | 0 Cargo.toml | 0 README.md | 0 flake.lock | 0 flake.nix | 0 nac3.svg | 0 nac3artiq/Cargo.toml | 0 nac3artiq/demo/demo.py | 0 nac3artiq/demo/device_db.py | 0 nac3artiq/demo/embedding_map.py | 0 nac3artiq/demo/min_artiq.py | 0 nac3artiq/src/codegen.rs | 0 nac3artiq/src/kernel.ld | 0 nac3artiq/src/lib.rs | 0 nac3artiq/src/symbol_resolver.rs | 0 nac3artiq/src/timeline.rs | 0 nac3ast/Cargo.toml | 0 nac3ast/Python.asdl | 0 nac3ast/asdl.py | 0 nac3ast/src/ast_gen.rs | 0 nac3ast/src/constant.rs | 0 nac3ast/src/fold_helpers.rs | 0 nac3ast/src/impls.rs | 0 nac3ast/src/lib.rs | 0 nac3ast/src/location.rs | 0 nac3core/Cargo.toml | 0 nac3core/build.rs | 0 nac3core/src/codegen/concrete_type.rs | 0 nac3core/src/codegen/expr.rs | 0 nac3core/src/codegen/generator.rs | 0 nac3core/src/codegen/irrt/irrt.c | 0 nac3core/src/codegen/irrt/mod.rs | 0 nac3core/src/codegen/mod.rs | 0 nac3core/src/codegen/stmt.rs | 0 nac3core/src/codegen/test.rs | 0 nac3core/src/lib.rs | 0 nac3core/src/symbol_resolver.rs | 0 nac3core/src/toplevel/builtins.rs | 6 ++ nac3core/src/toplevel/composer.rs | 91 +++++++++++++++++-- nac3core/src/toplevel/helper.rs | 1 + nac3core/src/toplevel/mod.rs | 2 + ...el__test__test_analyze__generic_class.snap | 0 ...t__test_analyze__inheritance_override.snap | 0 ...est__test_analyze__list_tuple_generic.snap | 0 ...__toplevel__test__test_analyze__self1.snap | 0 ...t__test_analyze__simple_class_compose.snap | 0 ...t__test_analyze__simple_pass_in_class.snap | 0 nac3core/src/toplevel/test.rs | 0 nac3core/src/toplevel/type_annotation.rs | 0 nac3core/src/typecheck/function_check.rs | 0 nac3core/src/typecheck/magic_methods.rs | 0 nac3core/src/typecheck/mod.rs | 0 nac3core/src/typecheck/type_error.rs | 0 nac3core/src/typecheck/type_inferencer/mod.rs | 0 .../src/typecheck/type_inferencer/test.rs | 0 nac3core/src/typecheck/typedef/mod.rs | 2 +- nac3core/src/typecheck/typedef/test.rs | 0 nac3core/src/typecheck/unification_table.rs | 0 nac3ld/Cargo.toml | 0 nac3ld/src/dwarf.rs | 0 nac3ld/src/elf.rs | 0 nac3ld/src/lib.rs | 0 nac3parser/Cargo.toml | 0 nac3parser/README.md | 0 nac3parser/build.rs | 0 nac3parser/src/config_comment_helper.rs | 0 nac3parser/src/error.rs | 0 nac3parser/src/fstring.rs | 0 nac3parser/src/function.rs | 0 nac3parser/src/lexer.rs | 0 nac3parser/src/lib.rs | 0 nac3parser/src/mode.rs | 0 nac3parser/src/parser.rs | 0 nac3parser/src/python.lalrpop | 0 ...s__fstring_parse_selfdocumenting_base.snap | 0 ...tring_parse_selfdocumenting_base_more.snap | 0 ..._fstring_parse_selfdocumenting_format.snap | 0 ...__fstring__tests__parse_empty_fstring.snap | 0 ...parser__fstring__tests__parse_fstring.snap | 0 ..._fstring__tests__parse_fstring_equals.snap | 0 ...ing__tests__parse_fstring_nested_spec.snap | 0 ...ring__tests__parse_fstring_not_equals.snap | 0 ..._tests__parse_fstring_not_nested_spec.snap | 0 ...sts__parse_fstring_selfdoc_prec_space.snap | 0 ..._parse_fstring_selfdoc_trailing_space.snap | 0 ...ring__tests__parse_fstring_yield_expr.snap | 0 ...ser__parser__tests__comment_ambiguity.snap | 0 ...c3parser__parser__tests__more_comment.snap | 0 ...ac3parser__parser__tests__parse_class.snap | 0 ...rser__tests__parse_dict_comprehension.snap | 0 ...ests__parse_double_list_comprehension.snap | 0 ...ac3parser__parser__tests__parse_empty.snap | 0 ...er__parser__tests__parse_if_elif_else.snap | 0 ...c3parser__parser__tests__parse_kwargs.snap | 0 ...c3parser__parser__tests__parse_lambda.snap | 0 ...rser__tests__parse_list_comprehension.snap | 0 ...3parser__parser__tests__parse_print_2.snap | 0 ...ser__parser__tests__parse_print_hello.snap | 0 ...c3parser__parser__tests__parse_tuples.snap | 0 ...parser__parser__tests__sample_comment.snap | 0 nac3parser/src/token.rs | 0 nac3standalone/Cargo.toml | 0 nac3standalone/demo/demo.rs | 0 nac3standalone/demo/src/classes.py | 0 nac3standalone/demo/src/default_param.py | 0 nac3standalone/demo/src/inheritance.py | 0 nac3standalone/demo/src/len.py | 0 nac3standalone/demo/src/lists.py | 0 nac3standalone/demo/src/loop.py | 0 nac3standalone/demo/src/mandelbrot.py | 0 nac3standalone/demo/src/min_max_abs.py | 0 nac3standalone/demo/src/operators.py | 0 nac3standalone/demo/src/option.py | 0 nac3standalone/demo/src/pow.py | 0 nac3standalone/demo/src/recursive_type.py | 0 nac3standalone/demo/src/tuple.py | 0 nac3standalone/demo/src/typevar.py | 0 nac3standalone/src/basic_symbol_resolver.rs | 0 nac3standalone/src/main.rs | 0 nix/llvm/TLI-musl.patch | 0 nix/llvm/default.nix | 0 nix/llvm/gnu-install-dirs.patch | 0 nix/llvm/llvm-future-riscv-abi.diff | 0 nix/llvm/outputs.patch | 0 nix/windows/PKGBUILD | 0 nix/windows/default.nix | 0 nix/windows/makepkg.conf | 0 nix/windows/msys2_packages.nix | 0 runkernel/Cargo.toml | 0 runkernel/build.rs | 0 runkernel/src/main.rs | 0 rustfmt.toml | 0 133 files changed, 101 insertions(+), 7 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 Cargo.lock mode change 100644 => 100755 Cargo.toml mode change 100644 => 100755 README.md mode change 100644 => 100755 flake.lock mode change 100644 => 100755 flake.nix mode change 100644 => 100755 nac3.svg mode change 100644 => 100755 nac3artiq/Cargo.toml mode change 100644 => 100755 nac3artiq/demo/demo.py mode change 100644 => 100755 nac3artiq/demo/device_db.py mode change 100644 => 100755 nac3artiq/demo/embedding_map.py mode change 100644 => 100755 nac3artiq/demo/min_artiq.py mode change 100644 => 100755 nac3artiq/src/codegen.rs mode change 100644 => 100755 nac3artiq/src/kernel.ld mode change 100644 => 100755 nac3artiq/src/lib.rs mode change 100644 => 100755 nac3artiq/src/symbol_resolver.rs mode change 100644 => 100755 nac3artiq/src/timeline.rs mode change 100644 => 100755 nac3ast/Cargo.toml mode change 100644 => 100755 nac3ast/Python.asdl mode change 100644 => 100755 nac3ast/asdl.py mode change 100644 => 100755 nac3ast/src/ast_gen.rs mode change 100644 => 100755 nac3ast/src/constant.rs mode change 100644 => 100755 nac3ast/src/fold_helpers.rs mode change 100644 => 100755 nac3ast/src/impls.rs mode change 100644 => 100755 nac3ast/src/lib.rs mode change 100644 => 100755 nac3ast/src/location.rs mode change 100644 => 100755 nac3core/Cargo.toml mode change 100644 => 100755 nac3core/build.rs mode change 100644 => 100755 nac3core/src/codegen/concrete_type.rs mode change 100644 => 100755 nac3core/src/codegen/expr.rs mode change 100644 => 100755 nac3core/src/codegen/generator.rs mode change 100644 => 100755 nac3core/src/codegen/irrt/irrt.c mode change 100644 => 100755 nac3core/src/codegen/irrt/mod.rs mode change 100644 => 100755 nac3core/src/codegen/mod.rs mode change 100644 => 100755 nac3core/src/codegen/stmt.rs mode change 100644 => 100755 nac3core/src/codegen/test.rs mode change 100644 => 100755 nac3core/src/lib.rs mode change 100644 => 100755 nac3core/src/symbol_resolver.rs mode change 100644 => 100755 nac3core/src/toplevel/builtins.rs mode change 100644 => 100755 nac3core/src/toplevel/composer.rs mode change 100644 => 100755 nac3core/src/toplevel/helper.rs mode change 100644 => 100755 nac3core/src/toplevel/mod.rs mode change 100644 => 100755 nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__generic_class.snap mode change 100644 => 100755 nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__inheritance_override.snap mode change 100644 => 100755 nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__list_tuple_generic.snap mode change 100644 => 100755 nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__self1.snap mode change 100644 => 100755 nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__simple_class_compose.snap mode change 100644 => 100755 nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__simple_pass_in_class.snap mode change 100644 => 100755 nac3core/src/toplevel/test.rs mode change 100644 => 100755 nac3core/src/toplevel/type_annotation.rs mode change 100644 => 100755 nac3core/src/typecheck/function_check.rs mode change 100644 => 100755 nac3core/src/typecheck/magic_methods.rs mode change 100644 => 100755 nac3core/src/typecheck/mod.rs mode change 100644 => 100755 nac3core/src/typecheck/type_error.rs mode change 100644 => 100755 nac3core/src/typecheck/type_inferencer/mod.rs mode change 100644 => 100755 nac3core/src/typecheck/type_inferencer/test.rs mode change 100644 => 100755 nac3core/src/typecheck/typedef/mod.rs mode change 100644 => 100755 nac3core/src/typecheck/typedef/test.rs mode change 100644 => 100755 nac3core/src/typecheck/unification_table.rs mode change 100644 => 100755 nac3ld/Cargo.toml mode change 100644 => 100755 nac3ld/src/dwarf.rs mode change 100644 => 100755 nac3ld/src/elf.rs mode change 100644 => 100755 nac3ld/src/lib.rs mode change 100644 => 100755 nac3parser/Cargo.toml mode change 100644 => 100755 nac3parser/README.md mode change 100644 => 100755 nac3parser/build.rs mode change 100644 => 100755 nac3parser/src/config_comment_helper.rs mode change 100644 => 100755 nac3parser/src/error.rs mode change 100644 => 100755 nac3parser/src/fstring.rs mode change 100644 => 100755 nac3parser/src/function.rs mode change 100644 => 100755 nac3parser/src/lexer.rs mode change 100644 => 100755 nac3parser/src/lib.rs mode change 100644 => 100755 nac3parser/src/mode.rs mode change 100644 => 100755 nac3parser/src/parser.rs mode change 100644 => 100755 nac3parser/src/python.lalrpop mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__fstring_parse_selfdocumenting_base.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__fstring_parse_selfdocumenting_base_more.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__fstring_parse_selfdocumenting_format.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__parse_empty_fstring.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_equals.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_nested_spec.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_not_equals.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_not_nested_spec.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_selfdoc_prec_space.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_selfdoc_trailing_space.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_yield_expr.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__comment_ambiguity.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__more_comment.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_class.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_dict_comprehension.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_double_list_comprehension.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_empty.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_if_elif_else.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_kwargs.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_lambda.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_list_comprehension.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_print_2.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_print_hello.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__parse_tuples.snap mode change 100644 => 100755 nac3parser/src/snapshots/nac3parser__parser__tests__sample_comment.snap mode change 100644 => 100755 nac3parser/src/token.rs mode change 100644 => 100755 nac3standalone/Cargo.toml mode change 100644 => 100755 nac3standalone/demo/demo.rs mode change 100644 => 100755 nac3standalone/demo/src/classes.py mode change 100644 => 100755 nac3standalone/demo/src/default_param.py mode change 100644 => 100755 nac3standalone/demo/src/inheritance.py mode change 100644 => 100755 nac3standalone/demo/src/len.py mode change 100644 => 100755 nac3standalone/demo/src/lists.py mode change 100644 => 100755 nac3standalone/demo/src/loop.py mode change 100644 => 100755 nac3standalone/demo/src/mandelbrot.py mode change 100644 => 100755 nac3standalone/demo/src/min_max_abs.py mode change 100644 => 100755 nac3standalone/demo/src/operators.py mode change 100644 => 100755 nac3standalone/demo/src/option.py mode change 100644 => 100755 nac3standalone/demo/src/pow.py mode change 100644 => 100755 nac3standalone/demo/src/recursive_type.py mode change 100644 => 100755 nac3standalone/demo/src/tuple.py mode change 100644 => 100755 nac3standalone/demo/src/typevar.py mode change 100644 => 100755 nac3standalone/src/basic_symbol_resolver.rs mode change 100644 => 100755 nac3standalone/src/main.rs mode change 100644 => 100755 nix/llvm/TLI-musl.patch mode change 100644 => 100755 nix/llvm/default.nix mode change 100644 => 100755 nix/llvm/gnu-install-dirs.patch mode change 100644 => 100755 nix/llvm/llvm-future-riscv-abi.diff mode change 100644 => 100755 nix/llvm/outputs.patch mode change 100644 => 100755 nix/windows/PKGBUILD mode change 100644 => 100755 nix/windows/default.nix mode change 100644 => 100755 nix/windows/makepkg.conf mode change 100644 => 100755 nix/windows/msys2_packages.nix mode change 100644 => 100755 runkernel/Cargo.toml mode change 100644 => 100755 runkernel/build.rs mode change 100644 => 100755 runkernel/src/main.rs mode change 100644 => 100755 rustfmt.toml diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index e68529b6..19165780 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ __pycache__ /target windows/msys2 +nac3standalone/demo/src/test.py +nac3standalone/demo/{ +interpreted.log +nac3standalone/demo/module.o +nac3standalone/demo/demo +nac3standalone/demo/run.log diff --git a/Cargo.lock b/Cargo.lock old mode 100644 new mode 100755 diff --git a/Cargo.toml b/Cargo.toml old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/flake.lock b/flake.lock old mode 100644 new mode 100755 diff --git a/flake.nix b/flake.nix old mode 100644 new mode 100755 diff --git a/nac3.svg b/nac3.svg old mode 100644 new mode 100755 diff --git a/nac3artiq/Cargo.toml b/nac3artiq/Cargo.toml old mode 100644 new mode 100755 diff --git a/nac3artiq/demo/demo.py b/nac3artiq/demo/demo.py old mode 100644 new mode 100755 diff --git a/nac3artiq/demo/device_db.py b/nac3artiq/demo/device_db.py old mode 100644 new mode 100755 diff --git a/nac3artiq/demo/embedding_map.py b/nac3artiq/demo/embedding_map.py old mode 100644 new mode 100755 diff --git a/nac3artiq/demo/min_artiq.py b/nac3artiq/demo/min_artiq.py old mode 100644 new mode 100755 diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs old mode 100644 new mode 100755 diff --git a/nac3artiq/src/kernel.ld b/nac3artiq/src/kernel.ld old mode 100644 new mode 100755 diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs old mode 100644 new mode 100755 diff --git a/nac3artiq/src/symbol_resolver.rs b/nac3artiq/src/symbol_resolver.rs old mode 100644 new mode 100755 diff --git a/nac3artiq/src/timeline.rs b/nac3artiq/src/timeline.rs old mode 100644 new mode 100755 diff --git a/nac3ast/Cargo.toml b/nac3ast/Cargo.toml old mode 100644 new mode 100755 diff --git a/nac3ast/Python.asdl b/nac3ast/Python.asdl old mode 100644 new mode 100755 diff --git a/nac3ast/asdl.py b/nac3ast/asdl.py old mode 100644 new mode 100755 diff --git a/nac3ast/src/ast_gen.rs b/nac3ast/src/ast_gen.rs old mode 100644 new mode 100755 diff --git a/nac3ast/src/constant.rs b/nac3ast/src/constant.rs old mode 100644 new mode 100755 diff --git a/nac3ast/src/fold_helpers.rs b/nac3ast/src/fold_helpers.rs old mode 100644 new mode 100755 diff --git a/nac3ast/src/impls.rs b/nac3ast/src/impls.rs old mode 100644 new mode 100755 diff --git a/nac3ast/src/lib.rs b/nac3ast/src/lib.rs old mode 100644 new mode 100755 diff --git a/nac3ast/src/location.rs b/nac3ast/src/location.rs old mode 100644 new mode 100755 diff --git a/nac3core/Cargo.toml b/nac3core/Cargo.toml old mode 100644 new mode 100755 diff --git a/nac3core/build.rs b/nac3core/build.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/codegen/concrete_type.rs b/nac3core/src/codegen/concrete_type.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/codegen/generator.rs b/nac3core/src/codegen/generator.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/codegen/irrt/irrt.c b/nac3core/src/codegen/irrt/irrt.c old mode 100644 new mode 100755 diff --git a/nac3core/src/codegen/irrt/mod.rs b/nac3core/src/codegen/irrt/mod.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/codegen/mod.rs b/nac3core/src/codegen/mod.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/codegen/stmt.rs b/nac3core/src/codegen/stmt.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/codegen/test.rs b/nac3core/src/codegen/test.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/lib.rs b/nac3core/src/lib.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/symbol_resolver.rs b/nac3core/src/symbol_resolver.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/toplevel/builtins.rs b/nac3core/src/toplevel/builtins.rs old mode 100644 new mode 100755 index 15fa2e07..78c5c71e --- a/nac3core/src/toplevel/builtins.rs +++ b/nac3core/src/toplevel/builtins.rs @@ -74,6 +74,8 @@ pub fn get_exn_constructor( constructor: Some(signature), resolver: None, loc: None, + // Make TopLevelDef::Class initlializer compatible + static_fields: Default::default(), }; (fun_def, class_def, signature, exn_type) } @@ -175,6 +177,8 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo { type_vars: Default::default(), fields: exception_fields, methods: Default::default(), + // Make TopLevelDef::Class initlializer compatible + static_fields: Default::default(), ancestors: vec![], constructor: None, resolver: None, @@ -200,6 +204,8 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo { object_id: DefinitionId(10), type_vars: vec![option_ty_var], fields: vec![], + // Make TopLevelDef::Class initlializer compatible + static_fields: vec![], methods: vec![ ("is_some".into(), is_some_ty.0, DefinitionId(11)), ("is_none".into(), is_some_ty.0, DefinitionId(12)), diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs old mode 100644 new mode 100755 index 16f508a7..b7cf694e --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -1040,6 +1040,7 @@ impl TopLevelComposer { class_body_ast, _class_ancestor_def, class_fields_def, + class_static_fields_def, // Introduce static class attribute list into the function class_methods_def, class_type_vars_def, class_resolver, @@ -1047,6 +1048,7 @@ impl TopLevelComposer { object_id, ancestors, fields, + static_fields, methods, resolver, type_vars, @@ -1054,7 +1056,7 @@ impl TopLevelComposer { } = &mut *class_def { if let ast::StmtKind::ClassDef { name, bases, body, .. } = &class_ast { - (*object_id, *name, bases, body, ancestors, fields, methods, type_vars, resolver) + (*object_id, *name, bases, body, ancestors, fields, static_fields, methods, type_vars, resolver) } else { unreachable!("here must be class def ast"); } @@ -1268,7 +1270,8 @@ impl TopLevelComposer { .unify(method_dummy_ty, method_type) .map_err(|e| e.to_display(unifier).to_string())?; } - ast::StmtKind::AnnAssign { target, annotation, value: None, .. } => { + // Reset value from none since fields in the form "ATTR_0: int32 = 10" need to be initialised + ast::StmtKind::AnnAssign { target, annotation, value, .. } => { if let ast::ExprKind::Name { id: attr, .. } = &target.node { if defined_fields.insert(attr.to_string()) { let dummy_field_type = unifier.get_dummy_var().0; @@ -1294,6 +1297,10 @@ impl TopLevelComposer { _ if core_config.kernel_ann.is_none() => (annotation, true), _ => continue, // ignore fields annotated otherwise }; + // If the value node is provided, then it must be a static class attribute + if let Option::Some(..) = &value{ + class_static_fields_def.push((*attr, dummy_field_type, mutable)); + } class_fields_def.push((*attr, dummy_field_type, mutable)); let parsed_annotation = parse_ast_to_type_annotation_kinds( @@ -1335,7 +1342,76 @@ impl TopLevelComposer { )); } } - ast::StmtKind::Assign { .. } => {}, // we don't class attributes + + // Add assign branch since fields in the form "ATTR_0 = 5" in the class body qualify as static class attributes + // However, type checking and expression folding needs to be performed in order to correctly + // Infer the type of target + ast::StmtKind::Assign { targets, value, .. } => { + // let ctx = Arc::new(self.make_top_level_context()); + + // let mut identifiers = { + // let mut result: HashSet<_> = HashSet::new(); + // if self_type.is_some() { + // result.insert("self".into()); + // } + // result.extend(inst_args.iter().map(|x| x.name)); + // result + // }; + // let mut calls: HashMap = HashMap::new(); + // let mut inferencer = Inferencer { + // top_level: ctx.as_ref(), + // defined_identifiers: identifiers.clone(), + // function_data: &mut FunctionData { + // resolver: class_resolver.as_ref().unwrap().clone(), + // return_type: if unifier.unioned(inst_ret, primitives_ty.none) { + // None + // } else { + // Some(inst_ret) + // }, + // // NOTE: allowed type vars + // bound_variables: no_range_vars.clone(), + // }, + // unifier, + // variable_mapping: { + // let mut result: HashMap = HashMap::new(); + // if let Some(self_ty) = self_type { + // result.insert("self".into(), self_ty); + // } + // result.extend(inst_args.iter().map(|x| (x.name, x.ty))); + // result + // }, + // primitives: primitives_ty, + // virtual_checks: &mut Vec::new(), + // calls: &mut calls, + // in_handler: false, + // }; + + for target in targets { + if let ast::ExprKind::Name { id: attr, .. } = &target.node { + if defined_fields.insert(attr.to_string()) { + let dummy_field_type = unifier.get_dummy_var().0; + + class_static_fields_def.push((*attr, dummy_field_type, true)); + class_fields_def.push((*attr, dummy_field_type, true)); + + // let value = inferencer.fold_expr(*value)?; + // let value_ty = value.custom.unwrap(); + + + } else { + return Err(format!( + "same class fields `{}` defined twice (at {})", + attr, target.location + )); + } + } else { + return Err(format!( + "unsupported statement type in class definition body (at {})", + target.location + )); + } + } + }, ast::StmtKind::Pass { .. } => {} ast::StmtKind::Expr { value: _, .. } => {} // typically a docstring; ignoring all expressions matches CPython behavior _ => { @@ -1516,6 +1592,7 @@ impl TopLevelComposer { ancestors, methods, fields, + static_fields, // Introduce static fields for (un)initialization check type_vars, name: class_name, object_id, @@ -1618,11 +1695,13 @@ impl TopLevelComposer { unreachable!("must be init function here") } let all_inited = Self::get_all_assigned_field(body.as_slice())?; - for (f, _, _) in fields { - if !all_inited.contains(f) { + // If a field is uninitialized but also a static class attribute, don't + // throw an error due to uninitialization + for f in fields { + if !all_inited.contains(&f.0) && !static_fields.contains(&f) { return Err(format!( "fields `{}` of class `{}` not fully initialized in the initializer (at {})", - f, + &f.0, class_name, body[0].location, )); diff --git a/nac3core/src/toplevel/helper.rs b/nac3core/src/toplevel/helper.rs old mode 100644 new mode 100755 index 73eebab5..77a3ba9e --- a/nac3core/src/toplevel/helper.rs +++ b/nac3core/src/toplevel/helper.rs @@ -162,6 +162,7 @@ impl TopLevelComposer { object_id: DefinitionId(index), type_vars: Default::default(), fields: Default::default(), + static_fields: Default::default(), // Initialize for constructor methods: Default::default(), ancestors: Default::default(), constructor, diff --git a/nac3core/src/toplevel/mod.rs b/nac3core/src/toplevel/mod.rs old mode 100644 new mode 100755 index 643594d4..16a7f0bf --- a/nac3core/src/toplevel/mod.rs +++ b/nac3core/src/toplevel/mod.rs @@ -92,6 +92,8 @@ pub enum TopLevelDef { // name, type, is mutable fields: Vec<(StrRef, Type, bool)>, // class methods, pointing to the corresponding function definition. + static_fields: Vec<(StrRef, Type, bool)>, + // list of static data members methods: Vec<(StrRef, Type, DefinitionId)>, // ancestor classes, including itself. ancestors: Vec, diff --git a/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__generic_class.snap b/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__generic_class.snap old mode 100644 new mode 100755 diff --git a/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__inheritance_override.snap b/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__inheritance_override.snap old mode 100644 new mode 100755 diff --git a/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__list_tuple_generic.snap b/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__list_tuple_generic.snap old mode 100644 new mode 100755 diff --git a/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__self1.snap b/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__self1.snap old mode 100644 new mode 100755 diff --git a/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__simple_class_compose.snap b/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__simple_class_compose.snap old mode 100644 new mode 100755 diff --git a/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__simple_pass_in_class.snap b/nac3core/src/toplevel/snapshots/nac3core__toplevel__test__test_analyze__simple_pass_in_class.snap old mode 100644 new mode 100755 diff --git a/nac3core/src/toplevel/test.rs b/nac3core/src/toplevel/test.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/toplevel/type_annotation.rs b/nac3core/src/toplevel/type_annotation.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/typecheck/function_check.rs b/nac3core/src/typecheck/function_check.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/typecheck/magic_methods.rs b/nac3core/src/typecheck/magic_methods.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/typecheck/mod.rs b/nac3core/src/typecheck/mod.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/typecheck/type_error.rs b/nac3core/src/typecheck/type_error.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/typecheck/type_inferencer/mod.rs b/nac3core/src/typecheck/type_inferencer/mod.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/typecheck/type_inferencer/test.rs b/nac3core/src/typecheck/type_inferencer/test.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/typecheck/typedef/mod.rs b/nac3core/src/typecheck/typedef/mod.rs old mode 100644 new mode 100755 index 861a2e37..fff88c30 --- a/nac3core/src/typecheck/typedef/mod.rs +++ b/nac3core/src/typecheck/typedef/mod.rs @@ -513,7 +513,7 @@ impl Unifier { fn unify_impl(&mut self, a: Type, b: Type, swapped: bool) -> Result<(), TypeError> { use TypeEnum::*; - + if !swapped { let rep_a = self.unification_table.get_representative(a); let rep_b = self.unification_table.get_representative(b); diff --git a/nac3core/src/typecheck/typedef/test.rs b/nac3core/src/typecheck/typedef/test.rs old mode 100644 new mode 100755 diff --git a/nac3core/src/typecheck/unification_table.rs b/nac3core/src/typecheck/unification_table.rs old mode 100644 new mode 100755 diff --git a/nac3ld/Cargo.toml b/nac3ld/Cargo.toml old mode 100644 new mode 100755 diff --git a/nac3ld/src/dwarf.rs b/nac3ld/src/dwarf.rs old mode 100644 new mode 100755 diff --git a/nac3ld/src/elf.rs b/nac3ld/src/elf.rs old mode 100644 new mode 100755 diff --git a/nac3ld/src/lib.rs b/nac3ld/src/lib.rs old mode 100644 new mode 100755 diff --git a/nac3parser/Cargo.toml b/nac3parser/Cargo.toml old mode 100644 new mode 100755 diff --git a/nac3parser/README.md b/nac3parser/README.md old mode 100644 new mode 100755 diff --git a/nac3parser/build.rs b/nac3parser/build.rs old mode 100644 new mode 100755 diff --git a/nac3parser/src/config_comment_helper.rs b/nac3parser/src/config_comment_helper.rs old mode 100644 new mode 100755 diff --git a/nac3parser/src/error.rs b/nac3parser/src/error.rs old mode 100644 new mode 100755 diff --git a/nac3parser/src/fstring.rs b/nac3parser/src/fstring.rs old mode 100644 new mode 100755 diff --git a/nac3parser/src/function.rs b/nac3parser/src/function.rs old mode 100644 new mode 100755 diff --git a/nac3parser/src/lexer.rs b/nac3parser/src/lexer.rs old mode 100644 new mode 100755 diff --git a/nac3parser/src/lib.rs b/nac3parser/src/lib.rs old mode 100644 new mode 100755 diff --git a/nac3parser/src/mode.rs b/nac3parser/src/mode.rs old mode 100644 new mode 100755 diff --git a/nac3parser/src/parser.rs b/nac3parser/src/parser.rs old mode 100644 new mode 100755 diff --git a/nac3parser/src/python.lalrpop b/nac3parser/src/python.lalrpop old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__fstring_parse_selfdocumenting_base.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__fstring_parse_selfdocumenting_base.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__fstring_parse_selfdocumenting_base_more.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__fstring_parse_selfdocumenting_base_more.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__fstring_parse_selfdocumenting_format.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__fstring_parse_selfdocumenting_format.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_empty_fstring.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_empty_fstring.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_equals.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_equals.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_nested_spec.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_nested_spec.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_not_equals.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_not_equals.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_not_nested_spec.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_not_nested_spec.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_selfdoc_prec_space.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_selfdoc_prec_space.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_selfdoc_trailing_space.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_selfdoc_trailing_space.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_yield_expr.snap b/nac3parser/src/snapshots/nac3parser__fstring__tests__parse_fstring_yield_expr.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__comment_ambiguity.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__comment_ambiguity.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__more_comment.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__more_comment.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_class.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_class.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_dict_comprehension.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_dict_comprehension.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_double_list_comprehension.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_double_list_comprehension.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_empty.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_empty.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_if_elif_else.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_if_elif_else.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_kwargs.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_kwargs.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_lambda.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_lambda.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_list_comprehension.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_list_comprehension.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_print_2.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_print_2.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_print_hello.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_print_hello.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__parse_tuples.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__parse_tuples.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/snapshots/nac3parser__parser__tests__sample_comment.snap b/nac3parser/src/snapshots/nac3parser__parser__tests__sample_comment.snap old mode 100644 new mode 100755 diff --git a/nac3parser/src/token.rs b/nac3parser/src/token.rs old mode 100644 new mode 100755 diff --git a/nac3standalone/Cargo.toml b/nac3standalone/Cargo.toml old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/demo.rs b/nac3standalone/demo/demo.rs old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/classes.py b/nac3standalone/demo/src/classes.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/default_param.py b/nac3standalone/demo/src/default_param.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/inheritance.py b/nac3standalone/demo/src/inheritance.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/len.py b/nac3standalone/demo/src/len.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/lists.py b/nac3standalone/demo/src/lists.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/loop.py b/nac3standalone/demo/src/loop.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/mandelbrot.py b/nac3standalone/demo/src/mandelbrot.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/min_max_abs.py b/nac3standalone/demo/src/min_max_abs.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/operators.py b/nac3standalone/demo/src/operators.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/option.py b/nac3standalone/demo/src/option.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/pow.py b/nac3standalone/demo/src/pow.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/recursive_type.py b/nac3standalone/demo/src/recursive_type.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/tuple.py b/nac3standalone/demo/src/tuple.py old mode 100644 new mode 100755 diff --git a/nac3standalone/demo/src/typevar.py b/nac3standalone/demo/src/typevar.py old mode 100644 new mode 100755 diff --git a/nac3standalone/src/basic_symbol_resolver.rs b/nac3standalone/src/basic_symbol_resolver.rs old mode 100644 new mode 100755 diff --git a/nac3standalone/src/main.rs b/nac3standalone/src/main.rs old mode 100644 new mode 100755 diff --git a/nix/llvm/TLI-musl.patch b/nix/llvm/TLI-musl.patch old mode 100644 new mode 100755 diff --git a/nix/llvm/default.nix b/nix/llvm/default.nix old mode 100644 new mode 100755 diff --git a/nix/llvm/gnu-install-dirs.patch b/nix/llvm/gnu-install-dirs.patch old mode 100644 new mode 100755 diff --git a/nix/llvm/llvm-future-riscv-abi.diff b/nix/llvm/llvm-future-riscv-abi.diff old mode 100644 new mode 100755 diff --git a/nix/llvm/outputs.patch b/nix/llvm/outputs.patch old mode 100644 new mode 100755 diff --git a/nix/windows/PKGBUILD b/nix/windows/PKGBUILD old mode 100644 new mode 100755 diff --git a/nix/windows/default.nix b/nix/windows/default.nix old mode 100644 new mode 100755 diff --git a/nix/windows/makepkg.conf b/nix/windows/makepkg.conf old mode 100644 new mode 100755 diff --git a/nix/windows/msys2_packages.nix b/nix/windows/msys2_packages.nix old mode 100644 new mode 100755 diff --git a/runkernel/Cargo.toml b/runkernel/Cargo.toml old mode 100644 new mode 100755 diff --git a/runkernel/build.rs b/runkernel/build.rs old mode 100644 new mode 100755 diff --git a/runkernel/src/main.rs b/runkernel/src/main.rs old mode 100644 new mode 100755 diff --git a/rustfmt.toml b/rustfmt.toml old mode 100644 new mode 100755 -- 2.44.1 From c3401cb17d942341ad14ca75bf75a66d0a38266f Mon Sep 17 00:00:00 2001 From: aadityavardhan Date: Sun, 21 Aug 2022 09:24:41 +0530 Subject: [PATCH 2/4] Removed unnecessary comments --- nac3core/src/toplevel/composer.rs | 42 ------------------------------- 1 file changed, 42 deletions(-) diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs index b7cf694e..9728636e 100755 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -1347,44 +1347,6 @@ impl TopLevelComposer { // However, type checking and expression folding needs to be performed in order to correctly // Infer the type of target ast::StmtKind::Assign { targets, value, .. } => { - // let ctx = Arc::new(self.make_top_level_context()); - - // let mut identifiers = { - // let mut result: HashSet<_> = HashSet::new(); - // if self_type.is_some() { - // result.insert("self".into()); - // } - // result.extend(inst_args.iter().map(|x| x.name)); - // result - // }; - // let mut calls: HashMap = HashMap::new(); - // let mut inferencer = Inferencer { - // top_level: ctx.as_ref(), - // defined_identifiers: identifiers.clone(), - // function_data: &mut FunctionData { - // resolver: class_resolver.as_ref().unwrap().clone(), - // return_type: if unifier.unioned(inst_ret, primitives_ty.none) { - // None - // } else { - // Some(inst_ret) - // }, - // // NOTE: allowed type vars - // bound_variables: no_range_vars.clone(), - // }, - // unifier, - // variable_mapping: { - // let mut result: HashMap = HashMap::new(); - // if let Some(self_ty) = self_type { - // result.insert("self".into(), self_ty); - // } - // result.extend(inst_args.iter().map(|x| (x.name, x.ty))); - // result - // }, - // primitives: primitives_ty, - // virtual_checks: &mut Vec::new(), - // calls: &mut calls, - // in_handler: false, - // }; for target in targets { if let ast::ExprKind::Name { id: attr, .. } = &target.node { @@ -1393,10 +1355,6 @@ impl TopLevelComposer { class_static_fields_def.push((*attr, dummy_field_type, true)); class_fields_def.push((*attr, dummy_field_type, true)); - - // let value = inferencer.fold_expr(*value)?; - // let value_ty = value.custom.unwrap(); - } else { return Err(format!( -- 2.44.1 From fc8b69c3cdb327b85b4a027cd4c56d61a1a6d697 Mon Sep 17 00:00:00 2001 From: Aadityavardhan Date: Sun, 21 Aug 2022 17:19:48 +0800 Subject: [PATCH 3/4] Updated .gitignore Removed unnecessary filenames --- .gitignore | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.gitignore b/.gitignore index 19165780..e68529b6 100755 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,3 @@ __pycache__ /target windows/msys2 -nac3standalone/demo/src/test.py -nac3standalone/demo/{ -interpreted.log -nac3standalone/demo/module.o -nac3standalone/demo/demo -nac3standalone/demo/run.log -- 2.44.1 From 170a1b8641f91cf7c2bdfeb81903b5f32cb14752 Mon Sep 17 00:00:00 2001 From: aadityavardhan Date: Sun, 21 Aug 2022 15:42:51 +0530 Subject: [PATCH 4/4] Fixed formatting and clutter --- nac3core/src/toplevel/builtins.rs | 3 --- nac3core/src/typecheck/typedef/mod.rs | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/nac3core/src/toplevel/builtins.rs b/nac3core/src/toplevel/builtins.rs index 78c5c71e..de3cc238 100755 --- a/nac3core/src/toplevel/builtins.rs +++ b/nac3core/src/toplevel/builtins.rs @@ -74,7 +74,6 @@ pub fn get_exn_constructor( constructor: Some(signature), resolver: None, loc: None, - // Make TopLevelDef::Class initlializer compatible static_fields: Default::default(), }; (fun_def, class_def, signature, exn_type) @@ -177,7 +176,6 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo { type_vars: Default::default(), fields: exception_fields, methods: Default::default(), - // Make TopLevelDef::Class initlializer compatible static_fields: Default::default(), ancestors: vec![], constructor: None, @@ -204,7 +202,6 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo { object_id: DefinitionId(10), type_vars: vec![option_ty_var], fields: vec![], - // Make TopLevelDef::Class initlializer compatible static_fields: vec![], methods: vec![ ("is_some".into(), is_some_ty.0, DefinitionId(11)), diff --git a/nac3core/src/typecheck/typedef/mod.rs b/nac3core/src/typecheck/typedef/mod.rs index fff88c30..861a2e37 100755 --- a/nac3core/src/typecheck/typedef/mod.rs +++ b/nac3core/src/typecheck/typedef/mod.rs @@ -513,7 +513,7 @@ impl Unifier { fn unify_impl(&mut self, a: Type, b: Type, swapped: bool) -> Result<(), TypeError> { use TypeEnum::*; - + if !swapped { let rep_a = self.unification_table.get_representative(a); let rep_b = self.unification_table.get_representative(b); -- 2.44.1