Skip to content

XML: LLVM + Typecheck (by Michael Gavrilenko, Danila Rudnev-Stepanyan and Daniel Vlasenko)#52

Open
spisladqo wants to merge 52 commits intoKakadu:masterfrom
qrutyy:feat/llvm
Open

XML: LLVM + Typecheck (by Michael Gavrilenko, Danila Rudnev-Stepanyan and Daniel Vlasenko)#52
spisladqo wants to merge 52 commits intoKakadu:masterfrom
qrutyy:feat/llvm

Conversation

@spisladqo
Copy link
Contributor

@spisladqo spisladqo commented Feb 16, 2026

Функциональность:

  • Добавил генерацию в IR LLVM всего, что было ранее: lib/backend/codegen_llvm.ml
  • Добавил type check + inference на основе алгоритма Реми с уровнями: lib/middleend/infer.ml

Тесты:

  • Добавил для кодгена IR LLVM все тесты, которые были для кодгена RISC-V (many_tests/codegen_llvm.t, llvm_tweaks.t, gc_llvm.t)
  • Для тайпчека написал unit-тесты (many_tests/unit/infer.ml) и добавил cram-тесты manytests (many_tests/infer.t)

and don't call function with uninitialized parameters
fixed: add rt_init and collect, calls to 0-arg funs, alloca dereference, offset in tuple elem loading, rt_init in rt, refactor code
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zanuda-linter report

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zanuda-linter report

@spisladqo spisladqo changed the title XML: LLVM (by Michael Gavrilenko, Danila Rudnev-Stepanyan and Daniel Vlasenko) XML: LLVM + Typecheck (by Michael Gavrilenko, Danila Rudnev-Stepanyan and Daniel Vlasenko) Mar 3, 2026
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zanuda-linter report

[%expect{| 'a -> 's |}]


let%expect_test _=
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test without description. Try `let%expect_test "name" = ...

[%expect{| ('b -> 'c) -> 'b -> 'c |}]


let%expect_test _ =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test without description. Try `let%expect_test "name" = ...

[%expect{| ('b -> 'c) -> 'b -> 'c |}]


let%expect_test _ =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test without description. Try `let%expect_test "name" = ...


(************************** Let in **************************)

let%expect_test _ =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test without description. Try `let%expect_test "name" = ...

[%expect{| int |}]


let%expect_test _ =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test without description. Try `let%expect_test "name" = ...

vb_list
;;

let rec get_pat_names acc pat =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Документация и тестовое покрытие (73.75%) должны скоро появиться.

https://kakadu.github.io/comp25/docs/XML

https://kakadu.github.io/comp25/cov/XML

2026-03-03 12:57

Email Commits Files Insertions Deletions Total Lines
vlasenko.daniil26@gmail.com 51 42 9069 5476 14545
qrutyq@gmail.com 52 58 7806 4255 12061
dabzelos@gmail.com 26 54 4661 1927 6588
----- ------- ----- ---------- --------- ---------

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zanuda-linter report

[%expect{| 'a -> 's |}]


let%expect_test _=
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test without description. Try `let%expect_test "name" = ...

[%expect{| ('b -> 'c) -> 'b -> 'c |}]


let%expect_test _ =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test without description. Try `let%expect_test "name" = ...

[%expect{| ('b -> 'c) -> 'b -> 'c |}]


let%expect_test _ =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test without description. Try `let%expect_test "name" = ...


(************************** Let in **************************)

let%expect_test _ =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test without description. Try `let%expect_test "name" = ...

[%expect{| int |}]


let%expect_test _ =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test without description. Try `let%expect_test "name" = ...

type env = (ident * TypeExpr.t) list

let gensym_counter = ref 0
let reset_gensym : unit -> unit = fun () -> gensym_counter := 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable references and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.


let gensym : unit -> string =
fun () ->
let n = !gensym_counter in
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable references and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.

if n < 26 then String.make 1 (Char.chr (Char.code 'a' + n)) else "t" ^ string_of_int n
;;

let newvar () = Type_var (ref (Unbound (gensym (), !current_level)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable references and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.

vb_list
;;

let rec get_pat_names acc pat =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

@@ -0,0 +1,397 @@
open Backend.Codegen_llvm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OCaml files should provide license information in second line (structure item)

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Linter report from 2026-03-03 12:58, for mini language XML

File "many_tests/unit/infer.ml", lines 260-262, characters 0-38:
260 | let%expect_test _=
261 |   infer_exp_str {| fun x -> fun y -> x y |};
262 |  [%expect{| ('b -> 'c) -> 'b -> 'c |}]
Alert zanuda-linter: A test without description. Try `let%expect_test "name" = ...
File "many_tests/unit/infer.ml", lines 265-267, characters 0-39:
265 | let%expect_test _ =
266 |   infer_exp_str {| fun x y -> x y |};
267 |   [%expect{| ('b -> 'c) -> 'b -> 'c |}]
Alert zanuda-linter: A test without description. Try `let%expect_test "name" = ...
File "many_tests/unit/infer.ml", lines 270-272, characters 0-68:
270 | let%expect_test _ =
271 |   infer_exp_str {| (fun f a b -> f a, f b) (fun x -> x) 1 "mystr" |};
272 |   [%expect{| Cannot unify different constructors: int and string |}]
Alert zanuda-linter: A test without description. Try `let%expect_test "name" = ...
File "many_tests/unit/infer.ml", lines 344-346, characters 0-20:
344 | let%expect_test _ =
345 |   infer_exp_str {| let 1 = 1 in 2 |};
346 |   [%expect{| int |}]
Alert zanuda-linter: A test without description. Try `let%expect_test "name" = ...
File "many_tests/unit/infer.ml", lines 349-351, characters 0-20:
349 | let%expect_test _ =
350 |   infer_exp_str {| let a = 1 in 2 |};
351 |   [%expect{| int |}]
Alert zanuda-linter: A test without description. Try `let%expect_test "name" = ...
File "many_tests/unit/infer.ml", lines 354-356, characters 0-20:
354 | let%expect_test _ =
355 | infer_exp_str {| let a = 1 in a |};
356 |   [%expect{| int |}]
Alert zanuda-linter: A test without description. Try `let%expect_test "name" = ...
File "many_tests/unit/infer.ml", lines 359-361, characters 0-23:
359 | let%expect_test _ =
360 |   infer_exp_str {| let a = 1 in "str" |};
361 |   [%expect{| string |}]
Alert zanuda-linter: A test without description. Try `let%expect_test "name" = ...
File "many_tests/unit/infer.ml", lines 380-382, characters 0-20:
380 | let%expect_test _ =
381 |   infer_exp_str  {| let a, b = 1, 2 in a |} ;
382 |   [%expect{| int |}]
Alert zanuda-linter: A test without description. Try `let%expect_test "name" = ...
File "many_tests/unit/infer.ml", lines 385-387, characters 0-55:
385 | let%expect_test _ =
386 |   infer_exp_str  {| let a, b, c = 1, 2 in a |} ;
387 |   [%expect{| Cannot unify tuples of different sizes |}]
Alert zanuda-linter: A test without description. Try `let%expect_test "name" = ...
File "many_tests/unit/infer.ml", lines 390-392, characters 0-55:
390 | let%expect_test _ =
391 |   infer_exp_str {| let a, b = 1, 2, 3 in a |};
392 |   [%expect{| Cannot unify tuples of different sizes |}]
Alert zanuda-linter: A test without description. Try `let%expect_test "name" = ...
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", lines 13-14, characters 4-3:
13 | ....mutable input_file_name : string option
14 |   ;.......................................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", lines 14-15, characters 4-3:
14 | ....mutable from_file_name : string option
15 |   ;.........................................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", lines 15-16, characters 4-3:
15 | ....mutable output_file_name : string option
16 |   ;.........................................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", lines 16-17, characters 4-3:
16 | ....mutable optimization_lvl : string option
17 |   ;........................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", lines 17-18, characters 4-3:
17 | ....mutable target : string
18 |   ;........................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", lines 18-19, characters 4-3:
18 | ....mutable show_ast : bool
19 |   ;........................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", lines 19-20, characters 4-3:
19 | ....mutable show_anf : bool
20 |   ;.......................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", lines 20-21, characters 4-3:
20 | ....mutable show_cc : bool
21 |   ;.......................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", lines 21-22, characters 4-3:
21 | ....mutable show_ll : bool
22 |   ;...........................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", lines 22-23, characters 4-3:
22 | ....mutable check_types : bool
23 |   ;..........................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/XML_llvm.ml", line 23, characters 4-29:
23 |   ; mutable show_types : bool
         ^^^^^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/backend/codegen_llvm.ml", line 147, characters 28-40:
147 |     (match Hashtbl.find_opt named_values id with
                                  ^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/backend/codegen_llvm.ml", line 246, characters 31-43:
246 |        (match Hashtbl.find_opt named_values f with
                                     ^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/backend/codegen_llvm.ml", line 319, characters 16-28:
319 |     Hashtbl.add named_values name alloca;
                      ^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/backend/codegen_llvm.ml", line 324, characters 16-28:
324 |   Hashtbl.clear named_values;
                      ^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/backend/codegen_llvm.ml", line 344, characters 19-31:
344 |        Hashtbl.add named_values name pval)
                         ^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/backend/codegen_llvm.ml", line 354, characters 23-35:
354 |        Hashtbl.replace named_values name alloca)
                             ^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/backend/codegen_llvm.ml", line 382, characters 16-28:
382 |     Hashtbl.add named_values name alloca;
                      ^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/common/ast.ml", line 100, characters 8-24:
100 |     map (fun x -> ref x) inner_gen
              ^^^^^^^^^^^^^^^^
Alert zanuda-linter: Eta reduction proposed. It's recommended to rewrite 
                     'fun x -> ref x' as 'ref'
File "lib/common/ast.ml", lines 105-116, characters 2-53:
105 | ..type t =
106 |     | Type_arrow of t * t
107 |     | Type_tuple of t List2.t
108 |     | Type_var of tv ref
109 |     | Quant_type_var of ident
...
113 |   and tv =
114 |     | Unbound of ident * level
115 |     | Link of t
116 |   [@@deriving eq, show { with_path = false }, qcheck]
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/common/ast.ml", line 108, characters 4-24:
108 |     | Type_var of tv ref
          ^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/common/ast.ml", line 108, characters 18-24:
108 |     | Type_var of tv ref
                        ^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/common/ast.mli", line 54, characters 4-25:
54 |     | Type_arrow of t * t
         ^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Constructor 'Type_arrow' has no documentation attribute
File "lib/common/ast.mli", line 55, characters 4-29:
55 |     | Type_tuple of t List2.t
         ^^^^^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Constructor 'Type_tuple' has no documentation attribute
File "lib/common/ast.mli", line 56, characters 4-24:
56 |     | Type_var of tv ref
         ^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Constructor 'Type_var' has no documentation attribute
File "lib/common/ast.mli", line 56, characters 18-24:
56 |     | Type_var of tv ref
                       ^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/common/ast.mli", line 57, characters 4-29:
57 |     | Quant_type_var of ident
         ^^^^^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Constructor 'Quant_type_var' has no documentation attribute
File "lib/common/ast.mli", line 58, characters 4-38:
58 |     | Type_construct of ident * t list
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Constructor 'Type_construct' has no documentation attribute
File "lib/common/ast.mli", line 61, characters 4-30:
61 |     | Unbound of ident * level
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Constructor 'Unbound' has no documentation attribute
File "lib/common/ast.mli", line 62, characters 4-15:
62 |     | Link of t
         ^^^^^^^^^^^
Alert zanuda-linter: Constructor 'Link' has no documentation attribute
File "lib/common/pprinter.ml", line 60, characters 14-20:
60 |       (match !tv_ref with
                   ^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/common/pprinter.ml", line 61, characters 31-37:
61 |        | Unbound _ -> Type_var tv_ref, var_map
                                    ^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/common/pprinter.ml", line 67, characters 20-31:
67 |          let idx = !var_counter in
                         ^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/common/pprinter.ml", line 68, characters 9-20:
68 |          var_counter := idx + 1;
              ^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 49, characters 26-39:
49 | let enter_level () = incr current_level
                               ^^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 50, characters 26-39:
50 | let leave_level () = decr current_level
                               ^^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 53, characters 22-24:
53 |   | Type_var tv' when tv == tv' -> fail Occurs_check
                           ^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 53, characters 22-31:
53 |   | Type_var tv' when tv == tv' -> fail Occurs_check
                           ^^^^^^^^^
Alert zanuda-linter: Do you really need physical equality? Physical means the equality of pointers.
File "lib/middleend/infer.ml", line 53, characters 28-31:
53 |   | Type_var tv' when tv == tv' -> fail Occurs_check
                                 ^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 56, characters 13-15:
56 |       match !tv with
                  ^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 60, characters 4-7:
60 |     tv' := Unbound (name, min_lvl);
         ^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 62, characters 51-53:
62 |   | Type_var { contents = Link t } -> occurs_check tv t
                                                        ^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 64, characters 27-29:
64 |     let* () = occurs_check tv t1 in
                                ^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 65, characters 27-29:
65 |     let* () = occurs_check tv t2 in
                                ^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 71, characters 22-24:
71 |          occurs_check tv t)
                           ^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 78, characters 22-24:
78 |          occurs_check tv t)
                           ^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 86, characters 16-24:
86 |   | t1, t2 when t1 == t2 -> return ()
                     ^^^^^^^^
Alert zanuda-linter: Do you really need physical equality? Physical means the equality of pointers.
File "lib/middleend/infer.ml", line 91, characters 27-29:
91 |     let* () = occurs_check tv t' in
                                ^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 92, characters 4-6:
92 |     tv := Link t';
         ^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 124, characters 57-70:
124 |   | Type_var { contents = Unbound (name, l) } when l >= !current_level ->
                                                               ^^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 137, characters 44-58:
137 | let reset_gensym : unit -> unit = fun () -> gensym_counter := 0
                                                  ^^^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 141, characters 11-25:
141 |   let n = !gensym_counter in
                 ^^^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", line 146, characters 52-65:
146 | let newvar () = Type_var (ref (Unbound (gensym (), !current_level)))
                                                          ^^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/middleend/infer.ml", lines 244-251, characters 26-12:
244 | ..........................pat =
245 |   match pat with
246 |   | Pat_var id -> id :: acc
247 |   | Pat_tuple (pat1, pat2, rest) ->
248 |     Base.List.fold_left ~f:get_pat_names ~init:acc (pat1 :: pat2 :: rest)
249 |   | Pat_construct ("Some", Some pat) -> get_pat_names acc pat
250 |   | Pat_constraint (pat, _) -> get_pat_names acc pat
251 |   | _ -> acc
Alert zanuda-linter: Using `function` is recommended
File "many_tests/unit/codegen_llvm.ml", line 1, characters 0-25:
1 | open Backend.Codegen_llvm
    ^^^^^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: OCaml files should provide license information in second line (structure item)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant