From 9d665ee3b0a3ca8408ef7da2a41a52d2b1a4d057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Th=C3=A9venoux?= Date: Fri, 29 Oct 2021 13:53:33 +0000 Subject: [PATCH] Lkt: use lkt_toolbox instead of lkt_resolve driver For convenience, get rid of the lkt_resolve driver and use lkt_toolbox to run Lkt's tests. TN: UA29-022 --- contrib/lkt/extensions/mains/lkt_toolbox.adb | 29 ++++++- .../liblktlang-implementation-extensions.adb | 26 +++--- contrib/lkt/language/parser.py | 11 +++ contrib/lkt/lkt_resolve.py | 87 ------------------- .../langkit_support-diagnostics-output.adb | 4 +- testsuite/drivers/lkt_resolve_driver.py | 19 ---- testsuite/drivers/lkt_toolbox_driver.py | 12 +++ .../lkt_semantic/ambiguous_type/test.out | 2 +- .../lkt_semantic/array_list_methods/test.out | 4 +- .../lkt_semantic/array_type_concrete/test.out | 32 +++---- .../lkt_semantic/array_type_expected/test.out | 36 ++++---- .../contrib/lkt_semantic/base_test/test.out | 22 ++--- .../lkt_semantic/basic_subtyping/test.out | 2 +- .../lkt_semantic/call_non_callable/test.out | 8 +- .../tests/contrib/lkt_semantic/cast/test.out | 4 +- .../decl_block_correctness/test.out | 34 ++++---- .../lkt_semantic/dot_call_invalid/test.out | 4 +- .../lkt_semantic/enum_subclasses/test.out | 8 +- .../erroneous_component_access/test.out | 2 +- .../lkt_semantic/generic_covariance/test.out | 2 +- .../generic_fn_instantiation/test.out | 14 +-- .../implicit_instantiation/test.out | 6 +- .../lkt_semantic/invalid_import/test.out | 2 +- .../lkt_semantic/invalid_type_ref/test.out | 6 +- .../contrib/lkt_semantic/lambda/test.out | 8 +- .../lkt_semantic/mismatching_actuals/test.out | 32 +++---- .../contrib/lkt_semantic/object_call/test.out | 18 ++-- .../lkt_semantic/property_error/test.out | 10 +-- testsuite/testsuite.py | 4 +- 29 files changed, 196 insertions(+), 252 deletions(-) delete mode 100644 contrib/lkt/lkt_resolve.py delete mode 100644 testsuite/drivers/lkt_resolve_driver.py create mode 100644 testsuite/drivers/lkt_toolbox_driver.py diff --git a/contrib/lkt/extensions/mains/lkt_toolbox.adb b/contrib/lkt/extensions/mains/lkt_toolbox.adb index ed9d6629d..e4e63b1b2 100644 --- a/contrib/lkt/extensions/mains/lkt_toolbox.adb +++ b/contrib/lkt/extensions/mains/lkt_toolbox.adb @@ -1,5 +1,6 @@ with Ada.Directories; use Ada.Directories; with Ada.Exceptions; +with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; @@ -14,7 +15,7 @@ use Langkit_Support.Diagnostics.Output; with Langkit_Support.Text; use Langkit_Support.Text; -with Liblktlang.Analysis; +with Liblktlang.Analysis; use Liblktlang.Analysis; with Liblktlang.Common; procedure Lkt_Toolbox is @@ -45,6 +46,20 @@ procedure Lkt_Toolbox is (S : Analysis.Semantic_Result; Unit : Analysis.Analysis_Unit); -- Print a semantic result + function Format_Node (Decl_Node : Decl'Class) return String; + -- Format node for semantic result printing + + ----------------- + -- Format_Node -- + ----------------- + + function Format_Node (Decl_Node : Decl'Class) return String is + begin + -- Remove rebindings information as there is no easy way to filter + -- out/format rebindings information involving prelude declarations. + return Decl_Node.P_As_Bare_Decl.Image; + end Format_Node; + --------------------------- -- Print_Semantic_Result -- --------------------------- @@ -75,7 +90,7 @@ procedure Lkt_Toolbox is and then not Analysis.Result_Ref (S).Is_Null then Put_Line ("Id " & Analysis.Node (S).Image); - Put_Line (" references " & Analysis.Result_Ref (S).Image); + Put_Line (" references " & Format_Node (Analysis.Result_Ref (S))); New_Line; end if; end Print_Semantic_Result; @@ -87,9 +102,15 @@ begin if Arg.Parser.Parse then for File_Name of Arg.Files.Get loop declare - Unit : constant Analysis.Analysis_Unit - := Ctx.Get_From_File (To_String (File_Name)); + File_Name_Str : constant String := To_String (File_Name); + Unit : constant Analysis.Analysis_Unit := + Ctx.Get_From_File (File_Name_Str); begin + if not Arg.Check_Only.Get then + Put_Line ("Resolving " & File_Name_Str); + Put_Line ((File_Name_Str'Length + 10) * "="); + end if; + if Unit.Diagnostics'Length > 0 then for Diagnostic of Unit.Diagnostics loop Print_Diagnostic diff --git a/contrib/lkt/extensions/src/liblktlang-implementation-extensions.adb b/contrib/lkt/extensions/src/liblktlang-implementation-extensions.adb index ece5ae04a..fc7e01075 100644 --- a/contrib/lkt/extensions/src/liblktlang-implementation-extensions.adb +++ b/contrib/lkt/extensions/src/liblktlang-implementation-extensions.adb @@ -74,18 +74,24 @@ package body Liblktlang.Implementation.Extensions is function Decl_Short_Image (Node : Bare_Decl) return Text_Type is Full_Name_Acc : String_Type := Dispatcher_Decl_P_Full_Name (Node); Full_Name : constant Text_Type := Full_Name_Acc.Content; + File_Name : constant Text_Type := + To_Text (Ada.Directories.Simple_Name (Get_Filename (Unit (Node)))); begin Dec_Ref (Full_Name_Acc); - return - "<" & To_Text (Kind_Name (Node)) & " """ & Full_Name & """ " - & To_Text (Ada.Directories.Simple_Name (Get_Filename (Unit (Node)))) - - -- Don't show the sloc for function types, because it will be the root - -- node's sloc, and thus will always change when we add stuff to the - -- file, which is not helpful nor practical for tests. - & (if Node.Kind = Lkt_Function_Type - then "" - else ":" & To_Text (Image (Sloc_Range (Node)))) & ">"; + if File_Name = "__prelude" then + return "<" & To_Text (Kind_Name (Node)) + & " prelude: """ & Full_Name & """>"; + else + return "<" & To_Text (Kind_Name (Node)) & " """ & Full_Name & """ " + & File_Name + + -- Don't show the sloc for function types, because it will be the + -- root node's sloc, and thus will always change when we add stuff + -- to the file, which is not helpful nor practical for tests. + & (if Node.Kind = Lkt_Function_Type + then "" + else ":" & To_Text (Image (Sloc_Range (Node)))) & ">"; + end if; end Decl_Short_Image; -------------------------------------- diff --git a/contrib/lkt/language/parser.py b/contrib/lkt/language/parser.py index 318de5072..90a29baa6 100644 --- a/contrib/lkt/language/parser.py +++ b/contrib/lkt/language/parser.py @@ -620,6 +620,17 @@ def assert_bare(): PropertyError(T.Decl, "Type decl has rebindings but shouldn't") ) + @langkit_property(public=True) + def as_bare_decl(): + """ + Get this declaration without rebindings information. + """ + # This is used by lkt_toolbox as a simple solution to filter out + # rebindings information for the prelude declarations. TODO: improve it + # in order to properly show rebindings information for prelude + # declarations (i.e. do not show sloc nor unit name). + return Entity.node.as_bare_entity + @langkit_property() def call_scope(): """ diff --git a/contrib/lkt/lkt_resolve.py b/contrib/lkt/lkt_resolve.py deleted file mode 100644 index 382118d5a..000000000 --- a/contrib/lkt/lkt_resolve.py +++ /dev/null @@ -1,87 +0,0 @@ -#! /usr/bin/env python - -from os import path as P - -from langkit.diagnostics import print_error_from_sem_result -from langkit.utils.colors import Colors, col, printcol - -import liblktlang as L - - -class Resolve(L.App): - """ - This script will resolve every type and RefId in a LKT source file. - """ - - def add_arguments(self): - self.parser.add_argument( - '-p', '--print-lkt', action="store_true", - help="Print the lkt source" - ) - self.parser.add_argument( - '-C', '--check-only', action="store_true", - help="Only print diagnostics" - ) - super(Resolve, self).add_arguments() - - def format_node(self, node: L.LKNode) -> str: - """ - Return ``str(node)`` except for declarations from the prelude, to avoid - sloc variability when the prelude changes. - """ - if ( - isinstance(node, L.Decl) - and P.basename(node.unit.filename) == "__prelude" - ): - return f'<{node.kind_name} prelude: "{node.p_full_name}">' - else: - return str(node) - - def main(self) -> None: - for unit_name, unit in self.units.items(): - if unit.diagnostics: - printcol("Syntax errors in {}, skipping".format( - P.basename(unit_name) - ), Colors.RED) - for diag in unit.diagnostics: - print(str(diag)) - continue - - if not self.args.check_only: - msg = "Resolving {}".format(unit_name) - print("{}\n{}".format(msg, "=" * len(msg))) - - if self.args.print_lkt: - print() - print("Source:") - print() - for i, l in enumerate(unit.root.text.splitlines()): - print("{: <3}: {}".format(i + 1, l)) - print() - - diags = unit.root.p_check_legality - - if self.args.check_only: - for diag in diags: - print_error_from_sem_result(diag) - else: - results = unit.root.p_check_semantic - for result in results.results: - if result.error_message: - print_error_from_sem_result(result) - elif result.result_type is not None: - print("Expr {}".format(self.format_node(result.node))) - print(" has type {}" - .format(self.format_node(result.result_type))) - print() - elif result.result_ref is not None: - print("Id {}".format(self.format_node(result.node))) - res = (" references {}" - .format(self.format_node(result.result_ref))) - print(col(res, Colors.RED) - if result.result_ref is None else res) - print() - - -if __name__ == '__main__': - Resolve.run() diff --git a/support/langkit_support-diagnostics-output.adb b/support/langkit_support-diagnostics-output.adb index 17ee58aec..2d4f8324a 100644 --- a/support/langkit_support-diagnostics-output.adb +++ b/support/langkit_support-diagnostics-output.adb @@ -66,7 +66,7 @@ package body Langkit_Support.Diagnostics.Output is Line_Nb : constant Positive := Positive (Sloc_Range.Start_Line); Start_Offset : constant Positive := Positive (Sloc_Range.Start_Column); - End_Offset : constant Positive := Positive (Sloc_Range.End_Column); + End_Offset : constant Positive := Positive (Sloc_Range.End_Column) - 1; Line_Nb_Width : constant Positive := Positive'Image (Line_Nb + Lines_After)'Length - 1; @@ -96,7 +96,7 @@ package body Langkit_Support.Diagnostics.Output is declare Caret_Line : Text_Type (1 .. End_Offset) := (others => ' '); begin - Caret_Line (Start_Offset .. End_Offset - 1) := (others => '^'); + Caret_Line (Start_Offset .. End_Offset) := (others => '^'); Put_Line (Output_File, Caret_Line); end; Reset_Colors; diff --git a/testsuite/drivers/lkt_resolve_driver.py b/testsuite/drivers/lkt_resolve_driver.py deleted file mode 100644 index ac00cd9da..000000000 --- a/testsuite/drivers/lkt_resolve_driver.py +++ /dev/null @@ -1,19 +0,0 @@ -from os import path as P - -from drivers.python_driver import PythonDriver - - -class LktResolveDriver(PythonDriver): - """ - Custom Python driver that will automatically run the "lkt_resolve.py" - script on the testcase's "test.lkt" file. - """ - - @property - def mandatory_files(self): - return ['test.lkt'] - - @property - def script_and_args(self): - LKT_LIB_DIR = P.join(self.langkit_root_dir, 'contrib', 'lkt') - return [P.join(LKT_LIB_DIR, 'lkt_resolve.py'), 'test.lkt'] diff --git a/testsuite/drivers/lkt_toolbox_driver.py b/testsuite/drivers/lkt_toolbox_driver.py new file mode 100644 index 000000000..d92d942d4 --- /dev/null +++ b/testsuite/drivers/lkt_toolbox_driver.py @@ -0,0 +1,12 @@ +from drivers.base_driver import BaseDriver + + +class LktToolboxDriver(BaseDriver): + """ + Custom driver that will automatically run the "lkt_toolbox" utility + on the testcase's "test.lkt" file. + """ + + def run(self): + self.run_and_check(['lkt_toolbox', 'test.lkt'], + memcheck=True, for_coverage=True) diff --git a/testsuite/tests/contrib/lkt_semantic/ambiguous_type/test.out b/testsuite/tests/contrib/lkt_semantic/ambiguous_type/test.out index 8fadfbf82..9e91cb923 100644 --- a/testsuite/tests/contrib/lkt_semantic/ambiguous_type/test.out +++ b/testsuite/tests/contrib/lkt_semantic/ambiguous_type/test.out @@ -1,6 +1,6 @@ Resolving test.lkt ================== test.lkt:4:9: error: ambiguous type for expression -3 | val a = "hello" +4 | val a = "hello" | ^^^^^^^ diff --git a/testsuite/tests/contrib/lkt_semantic/array_list_methods/test.out b/testsuite/tests/contrib/lkt_semantic/array_list_methods/test.out index 72e4eed9d..80823bc2b 100644 --- a/testsuite/tests/contrib/lkt_semantic/array_list_methods/test.out +++ b/testsuite/tests/contrib/lkt_semantic/array_list_methods/test.out @@ -85,6 +85,6 @@ Id references test.lkt:13:66: error: Cannot find entity `self` in this scope -12 | @invalid fun test_astlist_indexing(a: ASTList[String]): String = self(12) - | ^^^^ +13 | @invalid fun test_astlist_indexing(a: ASTList[String]): String = self(12) + | ^^^^ diff --git a/testsuite/tests/contrib/lkt_semantic/array_type_concrete/test.out b/testsuite/tests/contrib/lkt_semantic/array_type_concrete/test.out index 22112770c..80f7a2014 100644 --- a/testsuite/tests/contrib/lkt_semantic/array_type_concrete/test.out +++ b/testsuite/tests/contrib/lkt_semantic/array_type_concrete/test.out @@ -154,8 +154,8 @@ Expr has type String"> test.lkt:17:27: error: Mismatched types: expected `Int`, got `String` -16 | @invalid val a5 = [foo(), bar()] - | ^^^^^ +17 | @invalid val a5 = [foo(), bar()] + | ^^^^^ Expr has type @@ -164,12 +164,12 @@ Expr has type test.lkt:18:23: error: Mismatched types: expected `Int`, got a character literal -17 | @invalid val a6 = [1, '2', "3", foo(), bar()] - | ^^^ +18 | @invalid val a6 = [1, '2', "3", foo(), bar()] + | ^^^ test.lkt:18:28: error: Mismatched types: expected `Int`, got a string literal -17 | @invalid val a6 = [1, '2', "3", foo(), bar()] - | ^^^ +18 | @invalid val a6 = [1, '2', "3", foo(), bar()] + | ^^^ Id references @@ -187,11 +187,11 @@ Expr has type String"> test.lkt:18:40: error: Mismatched types: expected `Int`, got `String` -17 | @invalid val a6 = [1, '2', "3", foo(), bar()] - | ^^^^^ +18 | @invalid val a6 = [1, '2', "3", foo(), bar()] + | ^^^^^ test.lkt:18:19: error: ambiguous type for expression -17 | @invalid val a6 = [1, '2', "3", foo(), bar()] +18 | @invalid val a6 = [1, '2', "3", foo(), bar()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Id @@ -408,18 +408,18 @@ Expr has type test.lkt:31:36: error: Mismatched types: expected `String`, got a number literal -30 | @invalid val a11 = [[bar(), "2"], [1, 2]] - | ^ +31 | @invalid val a11 = [[bar(), "2"], [1, 2]] + | ^ test.lkt:31:39: error: Mismatched types: expected `String`, got a number literal -30 | @invalid val a11 = [[bar(), "2"], [1, 2]] - | ^ +31 | @invalid val a11 = [[bar(), "2"], [1, 2]] + | ^ test.lkt:31:35: error: Mismatched types: expected `Array[String]`, got an array -30 | @invalid val a11 = [[bar(), "2"], [1, 2]] - | ^^^^^^ +31 | @invalid val a11 = [[bar(), "2"], [1, 2]] + | ^^^^^^ test.lkt:31:20: error: ambiguous type for expression -30 | @invalid val a11 = [[bar(), "2"], [1, 2]] +31 | @invalid val a11 = [[bar(), "2"], [1, 2]] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testsuite/tests/contrib/lkt_semantic/array_type_expected/test.out b/testsuite/tests/contrib/lkt_semantic/array_type_expected/test.out index 6878c1d75..64d5dc5cd 100644 --- a/testsuite/tests/contrib/lkt_semantic/array_type_expected/test.out +++ b/testsuite/tests/contrib/lkt_semantic/array_type_expected/test.out @@ -46,19 +46,19 @@ Id references test.lkt:6:38: error: ambiguous type for expression -5 | @invalid val foo: LexicalEnv[Int] = [1] - | ^ +6 | @invalid val foo: LexicalEnv[Int] = [1] + | ^ test.lkt:6:37: error: Mismatched types: expected `LexicalEnv[Int]`, got an array -5 | @invalid val foo: LexicalEnv[Int] = [1] +6 | @invalid val foo: LexicalEnv[Int] = [1] | ^^^ test.lkt:10:19: error: ambiguous type for expression - 9 | @invalid val a2 = [] +10 | @invalid val a2 = [] | ^^ test.lkt:12:19: error: ambiguous type for expression -11 | @invalid val a3 = [1] +12 | @invalid val a3 = [1] | ^^^ Id @@ -107,11 +107,11 @@ Id references test.lkt:19:32: error: Mismatched types: expected `Int`, got a character literal -18 | @invalid val a5: Array[Int] = ['!'] - | ^^^ +19 | @invalid val a5: Array[Int] = ['!'] + | ^^^ test.lkt:19:31: error: Mismatched types: expected `Array[Int]`, got an array -18 | @invalid val a5: Array[Int] = ['!'] +19 | @invalid val a5: Array[Int] = ['!'] | ^^^^^ Id @@ -295,11 +295,11 @@ Id references test.lkt:32:39: error: Mismatched types: expected `Array[Int]`, got a number literal -31 | @invalid val a9: Array[Array[Int]] = [1] - | ^ +32 | @invalid val a9: Array[Array[Int]] = [1] + | ^ test.lkt:32:38: error: Mismatched types: expected `Array[Array[Int]]`, got an array -31 | @invalid val a9: Array[Array[Int]] = [1] +32 | @invalid val a9: Array[Array[Int]] = [1] | ^^^ Id @@ -312,18 +312,18 @@ Id references test.lkt:33:42: error: ambiguous type for expression -32 | @invalid val a10: Array[Array[Int]] = [[[1]]] - | ^ +33 | @invalid val a10: Array[Array[Int]] = [[[1]]] + | ^ test.lkt:33:41: error: Mismatched types: expected `Int`, got an array -32 | @invalid val a10: Array[Array[Int]] = [[[1]]] - | ^^^ +33 | @invalid val a10: Array[Array[Int]] = [[[1]]] + | ^^^ test.lkt:33:40: error: Mismatched types: expected `Array[Int]`, got an array -32 | @invalid val a10: Array[Array[Int]] = [[[1]]] - | ^^^^^ +33 | @invalid val a10: Array[Array[Int]] = [[[1]]] + | ^^^^^ test.lkt:33:39: error: Mismatched types: expected `Array[Array[Int]]`, got an array -32 | @invalid val a10: Array[Array[Int]] = [[[1]]] +33 | @invalid val a10: Array[Array[Int]] = [[[1]]] | ^^^^^^^ diff --git a/testsuite/tests/contrib/lkt_semantic/base_test/test.out b/testsuite/tests/contrib/lkt_semantic/base_test/test.out index dbd1b7055..05e74d7c8 100644 --- a/testsuite/tests/contrib/lkt_semantic/base_test/test.out +++ b/testsuite/tests/contrib/lkt_semantic/base_test/test.out @@ -19,7 +19,7 @@ Id references test.lkt:6:33: error: Mismatched types: expected `A`, got a number literal -5 | fun test_int_invalid(): A = 12 +6 | fun test_int_invalid(): A = 12 | ^^ Id @@ -38,8 +38,8 @@ Id references test.lkt:10:41: error: Mismatched types: expected `Int`, got a string literal - 9 | fun test_int_add_invalid_1(): Int = "12" + 15 - | ^^^^ +10 | fun test_int_add_invalid_1(): Int = "12" + 15 + | ^^^^ Expr has type @@ -57,7 +57,7 @@ Id references test.lkt:12:46: error: Mismatched types: expected `Int`, got `A` -11 | fun test_int_add_invalid_2(): Int = 15 + self +12 | fun test_int_add_invalid_2(): Int = 15 + self | ^^^^ Expr @@ -67,8 +67,8 @@ Id references test.lkt:14:39: error: Mismatched types: expected `A`, got a number literal -13 | fun test_int_add_invalid_3(): A = 15 + self - | ^^ +14 | fun test_int_add_invalid_3(): A = 15 + self + | ^^ Id references @@ -131,7 +131,7 @@ Expr has type test.lkt:25:56: error: Mismatched types: expected `Int`, got a string literal -24 | fun test_if_invalid_1(): Int = if true then 1 else "2" +25 | fun test_if_invalid_1(): Int = if true then 1 else "2" | ^^^ Expr @@ -231,7 +231,7 @@ Expr has type test.lkt:45:50: error: Mismatched types: expected `Pair[Int]`, got `Int` -44 | fun test_invalid_generic_type(): Pair[Int] = Pair[Int](12, 15).a +45 | fun test_invalid_generic_type(): Pair[Int] = Pair[Int](12, 15).a | ^^^^^^^^^^^^^^^^^^^ Id @@ -280,7 +280,7 @@ Id references test.lkt:47:60: error: Mismatched types: expected `Tuple2[Int, Bool]`, got `Bool` -46 | fun test_invalid_generic_type_2(): Tuple2[Int, Bool] = true +47 | fun test_invalid_generic_type_2(): Tuple2[Int, Bool] = true | ^^^^ Id @@ -374,7 +374,7 @@ Expr has type test.lkt:57:52: error: Cannot find entity `a` in this scope -56 | fun test_identifier_leak_invalid(): Int = self.a +57 | fun test_identifier_leak_invalid(): Int = self.a | ^ Id @@ -462,6 +462,6 @@ Expr has type Int"> test.lkt:69:58: error: Mismatched types: expected `(B) -> Int`, got `(A) -> Int` -68 | @invalid fun get_method_invalid(b_inst: B): (B) -> Int = b_inst.test_fun_call +69 | @invalid fun get_method_invalid(b_inst: B): (B) -> Int = b_inst.test_fun_call | ^^^^^^^^^^^^^^^^^^^^ diff --git a/testsuite/tests/contrib/lkt_semantic/basic_subtyping/test.out b/testsuite/tests/contrib/lkt_semantic/basic_subtyping/test.out index c33658020..52c0972ec 100644 --- a/testsuite/tests/contrib/lkt_semantic/basic_subtyping/test.out +++ b/testsuite/tests/contrib/lkt_semantic/basic_subtyping/test.out @@ -91,6 +91,6 @@ Id references test.lkt:18:58: error: Mismatched types: expected `Subclass2`, got `Subclass` -17 | @invalid fun test_subtyping_4 (a: Subclass): Subclass2 = a +18 | @invalid fun test_subtyping_4 (a: Subclass): Subclass2 = a | ^ diff --git a/testsuite/tests/contrib/lkt_semantic/call_non_callable/test.out b/testsuite/tests/contrib/lkt_semantic/call_non_callable/test.out index bdbee544f..91586bd00 100644 --- a/testsuite/tests/contrib/lkt_semantic/call_non_callable/test.out +++ b/testsuite/tests/contrib/lkt_semantic/call_non_callable/test.out @@ -13,8 +13,8 @@ Id references test.lkt:4:23: error: Object of type `Int` is not callable -3 | @invalid val b: Int = a(12)() - | ^^^^^ +4 | @invalid val b: Int = a(12)() + | ^^^^^ Id references @@ -53,8 +53,8 @@ Id references test.lkt:7:23: error: Object of type `Int` is not callable -6 | @invalid val d: Int = a(12)() - | ^^^^^ +7 | @invalid val d: Int = a(12)() + | ^^^^^ Id references diff --git a/testsuite/tests/contrib/lkt_semantic/cast/test.out b/testsuite/tests/contrib/lkt_semantic/cast/test.out index 3a4154c26..8cfc9e0bb 100644 --- a/testsuite/tests/contrib/lkt_semantic/cast/test.out +++ b/testsuite/tests/contrib/lkt_semantic/cast/test.out @@ -40,7 +40,7 @@ Id references test.lkt:6:19: error: Mismatched types: expected `Int`, got `ChildNode` -5 | @invalid c: Int = a.as[ChildNode] +6 | @invalid c: Int = a.as[ChildNode] | ^^^^^^^^^^^^^^^ Id @@ -59,6 +59,6 @@ Expr has type test.lkt:7:19: error: Invalid cast: only up/down casting allowed -6 | @invalid d: Int = a.as[Int] +7 | @invalid d: Int = a.as[Int] | ^^^^^^^^^ diff --git a/testsuite/tests/contrib/lkt_semantic/decl_block_correctness/test.out b/testsuite/tests/contrib/lkt_semantic/decl_block_correctness/test.out index c47f8ce1c..67167bb5f 100644 --- a/testsuite/tests/contrib/lkt_semantic/decl_block_correctness/test.out +++ b/testsuite/tests/contrib/lkt_semantic/decl_block_correctness/test.out @@ -1,23 +1,23 @@ Resolving test.lkt ================== test.lkt:5:4: error: value declaration forbidden in trait declaration -4 | @invalid val i: Int = 1 +5 | @invalid val i: Int = 1 | ^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:6:4: error: class declaration forbidden in trait declaration -5 | @invalid class MyClass {} +6 | @invalid class MyClass {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:7:4: error: generic class declaration forbidden in trait declaration -6 | @invalid generic[T] class MyGenClass {} +7 | @invalid generic[T] class MyGenClass {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:8:4: error: trait declaration forbidden in trait declaration -7 | @invalid trait InnerTrait {} +8 | @invalid trait InnerTrait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:9:4: error: field declaration forbidden in trait declaration -8 | @invalid field: Int = 1 +9 | @invalid field: Int = 1 | ^^^^^^^^^^^^^^^^^^^^^^^ Id @@ -57,11 +57,11 @@ Expr has type test.lkt:18:4: error: value declaration forbidden in enum declaration -17 | @invalid val i: Int = 1 +18 | @invalid val i: Int = 1 | ^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:19:4: error: generic class declaration forbidden in enum declaration -18 | @invalid generic[T] class MyGenClass {} +19 | @invalid generic[T] class MyGenClass {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Id @@ -71,15 +71,15 @@ Expr has type test.lkt:23:4: error: value declaration forbidden in struct declaration -22 | @invalid val i: Int = 1 +23 | @invalid val i: Int = 1 | ^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:24:4: error: struct declaration forbidden in struct declaration -23 | @invalid struct InnerStruct {} +24 | @invalid struct InnerStruct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:25:4: error: generic function declaration forbidden in struct declaration -24 | @invalid generic[T] fun MyGenFun(i: T): T = i +25 | @invalid generic[T] fun MyGenFun(i: T): T = i | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Id @@ -119,19 +119,19 @@ Expr has type test.lkt:32:4: error: value declaration forbidden in class declaration -31 | @invalid val i: Int = 1 +32 | @invalid val i: Int = 1 | ^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:33:4: error: class declaration forbidden in class declaration -32 | @invalid class InnerClass {} +33 | @invalid class InnerClass {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:34:4: error: generic trait declaration forbidden in class declaration -33 | @invalid generic[T] trait MyTrait {} +34 | @invalid generic[T] trait MyTrait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:35:4: error: generic field declaration forbidden in class declaration -34 | @invalid generic[T] gen_field: T +35 | @invalid generic[T] gen_field: T | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Id @@ -174,15 +174,15 @@ Expr has type test.lkt:43:4: error: value declaration forbidden in enum class declaration -42 | @invalid val i: Int = 1 +43 | @invalid val i: Int = 1 | ^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:44:4: error: field declaration forbidden in enum class declaration -43 | @invalid field: Int = 1 +44 | @invalid field: Int = 1 | ^^^^^^^^^^^^^^^^^^^^^^^ test.lkt:45:4: error: generic function declaration forbidden in enum class declaration -44 | @invalid generic[T] fun MyGenFun(i: T): T = i +45 | @invalid generic[T] fun MyGenFun(i: T): T = i | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Id diff --git a/testsuite/tests/contrib/lkt_semantic/dot_call_invalid/test.out b/testsuite/tests/contrib/lkt_semantic/dot_call_invalid/test.out index ce283da07..ac4b1cfbd 100644 --- a/testsuite/tests/contrib/lkt_semantic/dot_call_invalid/test.out +++ b/testsuite/tests/contrib/lkt_semantic/dot_call_invalid/test.out @@ -16,6 +16,6 @@ Expr has type test.lkt:4:25: error: Cannot find entity `plus` in this scope -3 | @invalid val b: Int = a.plus(2) - | ^^^^ +4 | @invalid val b: Int = a.plus(2) + | ^^^^ diff --git a/testsuite/tests/contrib/lkt_semantic/enum_subclasses/test.out b/testsuite/tests/contrib/lkt_semantic/enum_subclasses/test.out index 694cfb5c4..52146b928 100644 --- a/testsuite/tests/contrib/lkt_semantic/enum_subclasses/test.out +++ b/testsuite/tests/contrib/lkt_semantic/enum_subclasses/test.out @@ -16,10 +16,10 @@ Expr has type test.lkt:10:32: error: Cannot find entity `SubclassB` in this scope - 9 | @invalid val invalid_en_class: SubclassB = SubclassB() - | ^^^^^^^^^ +10 | @invalid val invalid_en_class: SubclassB = SubclassB() + | ^^^^^^^^^ test.lkt:10:44: error: Cannot find entity `SubclassB` in this scope - 9 | @invalid val invalid_en_class: SubclassB = SubclassB() - | ^^^^^^^^^ +10 | @invalid val invalid_en_class: SubclassB = SubclassB() + | ^^^^^^^^^ diff --git a/testsuite/tests/contrib/lkt_semantic/erroneous_component_access/test.out b/testsuite/tests/contrib/lkt_semantic/erroneous_component_access/test.out index 6fa24f5ff..e19c9a6b8 100644 --- a/testsuite/tests/contrib/lkt_semantic/erroneous_component_access/test.out +++ b/testsuite/tests/contrib/lkt_semantic/erroneous_component_access/test.out @@ -4,7 +4,7 @@ Id references test.lkt:1:19: error: Cannot find entity `Cls` in this scope -0 | fun test(a: Int): Cls +1 | fun test(a: Int): Cls | ^^^ Id diff --git a/testsuite/tests/contrib/lkt_semantic/generic_covariance/test.out b/testsuite/tests/contrib/lkt_semantic/generic_covariance/test.out index 1ccb84139..c7b484385 100644 --- a/testsuite/tests/contrib/lkt_semantic/generic_covariance/test.out +++ b/testsuite/tests/contrib/lkt_semantic/generic_covariance/test.out @@ -43,6 +43,6 @@ Id references test.lkt:14:37: error: Mismatched types: expected `TestEntity[Statement]`, got `TestEntity[Lit]` -13 | @invalid C: TestEntity[Statement] = A +14 | @invalid C: TestEntity[Statement] = A | ^ diff --git a/testsuite/tests/contrib/lkt_semantic/generic_fn_instantiation/test.out b/testsuite/tests/contrib/lkt_semantic/generic_fn_instantiation/test.out index fc931c89c..8959be710 100644 --- a/testsuite/tests/contrib/lkt_semantic/generic_fn_instantiation/test.out +++ b/testsuite/tests/contrib/lkt_semantic/generic_fn_instantiation/test.out @@ -247,7 +247,7 @@ Id references test.lkt:56:60: error: Not enough information to infer instantiation of generic callee -55 | @invalid fun test_ambiguous_generic_instantiation(): Int = fooz(1, "lol") +56 | @invalid fun test_ambiguous_generic_instantiation(): Int = fooz(1, "lol") | ^^^^^^^^^^^^^^ Id @@ -263,8 +263,8 @@ Id references test.lkt:59:63: error: Mismatched types: expected `Int`, got a string literal -58 | @invalid fun test_invalid_singleton(): Array[Int] = singleton("lol") - | ^^^^^ +59 | @invalid fun test_invalid_singleton(): Array[Int] = singleton("lol") + | ^^^^^ Expr has type @@ -273,7 +273,7 @@ Id references test.lkt:62:48: error: Cannot instantiate callee: cannot unify `Array[T]` with `Int` -61 | @invalid fun test_invalid_singleton_2(): Int = singleton("lol") +62 | @invalid fun test_invalid_singleton_2(): Int = singleton("lol") | ^^^^^^^^^^^^^^^^ Id @@ -289,7 +289,7 @@ Id references test.lkt:68:63: error: Cannot instantiate callee: cannot unify `Array[T]` with `Dummy[Int, String]` -67 | @invalid fun test_invalid_singleton_3(): Dummy[Int, String] = singleton("lol") +68 | @invalid fun test_invalid_singleton_3(): Dummy[Int, String] = singleton("lol") | ^^^^^^^^^^^^^^^^ Id @@ -374,8 +374,8 @@ Expr has type Int"> test.lkt:78:18: error: Cannot find entity `xxx` in this scope -77 | (yyy) => xxx * yyy - | ^^^ +78 | (yyy) => xxx * yyy + | ^^^ Id references diff --git a/testsuite/tests/contrib/lkt_semantic/implicit_instantiation/test.out b/testsuite/tests/contrib/lkt_semantic/implicit_instantiation/test.out index dc51a04f5..aea35b44c 100644 --- a/testsuite/tests/contrib/lkt_semantic/implicit_instantiation/test.out +++ b/testsuite/tests/contrib/lkt_semantic/implicit_instantiation/test.out @@ -145,8 +145,8 @@ Expr has type test.lkt:36:40: error: Cannot find entity `A` in this scope -35 | @invalid fun test_handle_ce_error(arg: A): Int = arg.method_doesnt_exist() - | ^ +36 | @invalid fun test_handle_ce_error(arg: A): Int = arg.method_doesnt_exist() + | ^ Id references @@ -176,7 +176,7 @@ Id references test.lkt:43:60: error: Instantiation error: conflicting actual types for formal `T`: `Int` and `Bool` -42 | @invalid fun test_conflicting_actuals(): Pair[Int, Bool] = mkPair(1) +43 | @invalid fun test_conflicting_actuals(): Pair[Int, Bool] = mkPair(1) | ^^^^^^^^^ Id diff --git a/testsuite/tests/contrib/lkt_semantic/invalid_import/test.out b/testsuite/tests/contrib/lkt_semantic/invalid_import/test.out index 602f871f1..e38f2d495 100644 --- a/testsuite/tests/contrib/lkt_semantic/invalid_import/test.out +++ b/testsuite/tests/contrib/lkt_semantic/invalid_import/test.out @@ -1,6 +1,6 @@ Resolving test.lkt ================== test.lkt:1:1: error: cannot find invalid_import -0 | import invalid_import +1 | import invalid_import | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/testsuite/tests/contrib/lkt_semantic/invalid_type_ref/test.out b/testsuite/tests/contrib/lkt_semantic/invalid_type_ref/test.out index e251d945e..e82e201df 100644 --- a/testsuite/tests/contrib/lkt_semantic/invalid_type_ref/test.out +++ b/testsuite/tests/contrib/lkt_semantic/invalid_type_ref/test.out @@ -1,15 +1,15 @@ Resolving test.lkt ================== test.lkt:5:4: error: Invalid type reference -4 | a: U +5 | a: U | ^ Id references test.lkt:7:10: error: Invalid type reference -6 | class V: U { - | ^ +7 | class V: U { + | ^ Id references diff --git a/testsuite/tests/contrib/lkt_semantic/lambda/test.out b/testsuite/tests/contrib/lkt_semantic/lambda/test.out index 05dbf5285..aa476c4c9 100644 --- a/testsuite/tests/contrib/lkt_semantic/lambda/test.out +++ b/testsuite/tests/contrib/lkt_semantic/lambda/test.out @@ -68,8 +68,8 @@ Expr test.lkt:12:29: error: Invalid type annotations for lambda parameters. Annotate either all or no params -11 | lambda_test_helper(12, (x: Int, y) => x + y * 2) - | ^^^^^^^^^ +12 | lambda_test_helper(12, (x: Int, y) => x + y * 2) + | ^^^^^^^^^ Id references @@ -126,8 +126,8 @@ Expr has type test.lkt:16:28: error: Mismatched types: expected `(Int, Int) -> Int`, got `(String, String) -> Int` -15 | lambda_test_helper(12, (x: String, y: String): Int => 12) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +16 | lambda_test_helper(12, (x: String, y: String): Int => 12) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Expr has type diff --git a/testsuite/tests/contrib/lkt_semantic/mismatching_actuals/test.out b/testsuite/tests/contrib/lkt_semantic/mismatching_actuals/test.out index 474769e21..1f368a0a2 100644 --- a/testsuite/tests/contrib/lkt_semantic/mismatching_actuals/test.out +++ b/testsuite/tests/contrib/lkt_semantic/mismatching_actuals/test.out @@ -46,8 +46,8 @@ Id references test.lkt:6:23: error: No value for parameter `b` in call to `test` -5 | @invalid val u: Int = test(12) # Missing params - | ^^^^^^^^ +6 | @invalid val u: Int = test(12) # Missing params + | ^^^^^^^^ Id references @@ -65,8 +65,8 @@ Id references test.lkt:7:23: error: No value for parameter `a` in call to `test` -6 | @invalid val v: Int = test(b=12) # Missing params in call with kwargs - | ^^^^^^^^^^ +7 | @invalid val v: Int = test(b=12) # Missing params in call with kwargs + | ^^^^^^^^^^ Id references @@ -90,8 +90,8 @@ Id references test.lkt:8:36: error: Unmatched actual in call to `test` -7 | @invalid val x: Int = test(12, 15, 17) # Too many params - | ^^ +8 | @invalid val x: Int = test(12, 15, 17) # Too many params + | ^^ Id references @@ -106,8 +106,8 @@ Expr has type test.lkt:8:36: error: ambiguous type for expression -7 | @invalid val x: Int = test(12, 15, 17) # Too many params - | ^^ +8 | @invalid val x: Int = test(12, 15, 17) # Too many params + | ^^ Expr has type @@ -116,8 +116,8 @@ Id references test.lkt:9:39: error: Unmatched actual in call to `test` -8 | @invalid val y: Int = test(a=1, b=12, c=15) # Too many params kwargs - | ^^^^ +9 | @invalid val y: Int = test(a=1, b=12, c=15) # Too many params kwargs + | ^^^^ Id references @@ -144,8 +144,8 @@ Expr has type test.lkt:9:41: error: ambiguous type for expression -8 | @invalid val y: Int = test(a=1, b=12, c=15) # Too many params kwargs - | ^^ +9 | @invalid val y: Int = test(a=1, b=12, c=15) # Too many params kwargs + | ^^ Expr has type @@ -154,8 +154,8 @@ Id references test.lkt:10:39: error: Unmatched actual in call to `test` - 9 | @invalid val z: Int = test(a=1, b=12, c=foo) # Invalid kwarg with wrong value: check that there is an error message for the expr - | ^^^^^ +10 | @invalid val z: Int = test(a=1, b=12, c=foo) # Invalid kwarg with wrong value: check that there is an error message for the expr + | ^^^^^ Id references @@ -182,8 +182,8 @@ Expr has type test.lkt:10:41: error: Cannot find entity `foo` in this scope - 9 | @invalid val z: Int = test(a=1, b=12, c=foo) # Invalid kwarg with wrong value: check that there is an error message for the expr - | ^^^ +10 | @invalid val z: Int = test(a=1, b=12, c=foo) # Invalid kwarg with wrong value: check that there is an error message for the expr + | ^^^ Expr has type diff --git a/testsuite/tests/contrib/lkt_semantic/object_call/test.out b/testsuite/tests/contrib/lkt_semantic/object_call/test.out index 08b685330..b8a06d4c3 100644 --- a/testsuite/tests/contrib/lkt_semantic/object_call/test.out +++ b/testsuite/tests/contrib/lkt_semantic/object_call/test.out @@ -46,8 +46,8 @@ Expr has type test.lkt:7:46: error: Mismatched types: expected `Int`, got a string literal -6 | @incorrect val incorrect_call: Int = arr(12)("a") - | ^^^ +7 | @incorrect val incorrect_call: Int = arr(12)("a") + | ^^^ Expr has type @@ -56,7 +56,7 @@ Id references test.lkt:8:40: error: No value for parameter -7 | @incorrect val incorrect_call_1: Int = arr(12)() +8 | @incorrect val incorrect_call_1: Int = arr(12)() | ^^^^^^^^^ Id @@ -78,8 +78,8 @@ Id references test.lkt:9:51: error: Unmatched actual -8 | @incorrect val incorrect_call_2: Int = arr(12)(1, 2) - | ^ +9 | @incorrect val incorrect_call_2: Int = arr(12)(1, 2) + | ^ Id references @@ -97,8 +97,8 @@ Expr has type test.lkt:9:51: error: ambiguous type for expression -8 | @incorrect val incorrect_call_2: Int = arr(12)(1, 2) - | ^ +9 | @incorrect val incorrect_call_2: Int = arr(12)(1, 2) + | ^ Expr has type @@ -149,8 +149,8 @@ Expr has type test.lkt:14:42: error: Mismatched types: expected `Int`, got a character literal -13 | @incorrect val b: Int = return_func()(1, '2') - | ^^^ +14 | @incorrect val b: Int = return_func()(1, '2') + | ^^^ Expr has type diff --git a/testsuite/tests/contrib/lkt_semantic/property_error/test.out b/testsuite/tests/contrib/lkt_semantic/property_error/test.out index 7e5f23a1b..9cf7ba7b5 100644 --- a/testsuite/tests/contrib/lkt_semantic/property_error/test.out +++ b/testsuite/tests/contrib/lkt_semantic/property_error/test.out @@ -43,7 +43,7 @@ Expr has type test.lkt:5:28: error: Mismatched types: expected `Bool`, got `PropertyError` -4 | @invalid val prop3: Bool = PropertyError("error") +5 | @invalid val prop3: Bool = PropertyError("error") | ^^^^^^^^^^^^^^^^^^^^^^ Id @@ -56,11 +56,11 @@ Expr has type test.lkt:6:29: error: Mismatched types: expected `Bool`, got `PropertyError` -5 | @invalid val prop4: Bool = (PropertyError("error")) - | ^^^^^^^^^^^^^^^^^^^^^^ +6 | @invalid val prop4: Bool = (PropertyError("error")) + | ^^^^^^^^^^^^^^^^^^^^^^ test.lkt:6:28: error: Mismatched types: expected `Bool`, got `PropertyError` -5 | @invalid val prop4: Bool = (PropertyError("error")) +6 | @invalid val prop4: Bool = (PropertyError("error")) | ^^^^^^^^^^^^^^^^^^^^^^^^ Id @@ -97,7 +97,7 @@ Id references test.lkt:16:36: error: raised expression needs to be of type `PropertyError`, got `Int` -15 | @invalid fun prop6(): Bool = raise i +16 | @invalid fun prop6(): Bool = raise i | ^ Id diff --git a/testsuite/testsuite.py b/testsuite/testsuite.py index 1febcce54..18400d970 100755 --- a/testsuite/testsuite.py +++ b/testsuite/testsuite.py @@ -17,7 +17,7 @@ from e3.testsuite import Testsuite import drivers.langkit_support_driver -import drivers.lkt_resolve_driver +import drivers.lkt_toolbox_driver import drivers.python_driver @@ -37,7 +37,7 @@ class LangkitTestsuite(Testsuite): test_driver_map = { 'python': drivers.python_driver.PythonDriver, 'langkit_support': drivers.langkit_support_driver.LangkitSupportDriver, - 'lkt': drivers.lkt_resolve_driver.LktResolveDriver, + 'lkt': drivers.lkt_toolbox_driver.LktToolboxDriver, } def add_options(self, parser):