From 9cd40d0903b58bb4a7b48984f49e74eadcaf60b6 Mon Sep 17 00:00:00 2001 From: degory Date: Mon, 15 Apr 2024 20:51:23 +0200 Subject: [PATCH] Fix missing argument IL value --- Directory.Build.props | 2 +- .../.vscode/tasks.json | 23 +++++++++++++++++++ .../err.expected | 0 .../ghul.json | 3 +++ .../ghulflags | 1 + .../il.expected | 0 .../run.expected | 1 + .../test.ghul | 18 +++++++++++++++ .../warn.expected | 0 src/syntax/process/compile_expressions.ghul | 6 +++-- 10 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 integration-tests/execution/expression-if-constructor-argument-1/.vscode/tasks.json create mode 100644 integration-tests/execution/expression-if-constructor-argument-1/err.expected create mode 100644 integration-tests/execution/expression-if-constructor-argument-1/ghul.json create mode 100644 integration-tests/execution/expression-if-constructor-argument-1/ghulflags create mode 100644 integration-tests/execution/expression-if-constructor-argument-1/il.expected create mode 100644 integration-tests/execution/expression-if-constructor-argument-1/run.expected create mode 100644 integration-tests/execution/expression-if-constructor-argument-1/test.ghul create mode 100644 integration-tests/execution/expression-if-constructor-argument-1/warn.expected diff --git a/Directory.Build.props b/Directory.Build.props index ff68a0442..6e13160a1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 0.8.42-alpha.124 + 0.8.42-alpha.125 $(NoWarn);NU1507 diff --git a/integration-tests/execution/expression-if-constructor-argument-1/.vscode/tasks.json b/integration-tests/execution/expression-if-constructor-argument-1/.vscode/tasks.json new file mode 100644 index 000000000..49063613c --- /dev/null +++ b/integration-tests/execution/expression-if-constructor-argument-1/.vscode/tasks.json @@ -0,0 +1,23 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Run test", + "command": "dotnet ghul-test \"${workspaceFolder}\"", + "type": "shell", + "group": { + "kind": "test", + "isDefault": true + } + }, + { + "label": "Capture test expectation", + "command": "../../../tasks/capture.sh \"${workspaceFolder}\"", + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/integration-tests/execution/expression-if-constructor-argument-1/err.expected b/integration-tests/execution/expression-if-constructor-argument-1/err.expected new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/execution/expression-if-constructor-argument-1/ghul.json b/integration-tests/execution/expression-if-constructor-argument-1/ghul.json new file mode 100644 index 000000000..ddcfcf2b1 --- /dev/null +++ b/integration-tests/execution/expression-if-constructor-argument-1/ghul.json @@ -0,0 +1,3 @@ +{ + "compiler": "dotnet ../../../publish/ghul.dll" +} diff --git a/integration-tests/execution/expression-if-constructor-argument-1/ghulflags b/integration-tests/execution/expression-if-constructor-argument-1/ghulflags new file mode 100644 index 000000000..7a27fea4a --- /dev/null +++ b/integration-tests/execution/expression-if-constructor-argument-1/ghulflags @@ -0,0 +1 @@ +--dotnet \ No newline at end of file diff --git a/integration-tests/execution/expression-if-constructor-argument-1/il.expected b/integration-tests/execution/expression-if-constructor-argument-1/il.expected new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/execution/expression-if-constructor-argument-1/run.expected b/integration-tests/execution/expression-if-constructor-argument-1/run.expected new file mode 100644 index 000000000..c8802ca0d --- /dev/null +++ b/integration-tests/execution/expression-if-constructor-argument-1/run.expected @@ -0,0 +1 @@ +construct THING(123,'hello',False) diff --git a/integration-tests/execution/expression-if-constructor-argument-1/test.ghul b/integration-tests/execution/expression-if-constructor-argument-1/test.ghul new file mode 100644 index 000000000..85b97f086 --- /dev/null +++ b/integration-tests/execution/expression-if-constructor-argument-1/test.ghul @@ -0,0 +1,18 @@ +use IO.Std.write_line; + +class Main is + entry() static is + let t1 = + THING( + if true then 123 else 456 fi, + if false then "goodbye" else "hello" fi, + if true then false else true fi + ); + si +si + +class THING is + init(a: int, b: string, c: bool) is + write_line("construct THING({a},'{b}',{c})"); + si +si diff --git a/integration-tests/execution/expression-if-constructor-argument-1/warn.expected b/integration-tests/execution/expression-if-constructor-argument-1/warn.expected new file mode 100644 index 000000000..e69de29bb diff --git a/src/syntax/process/compile_expressions.ghul b/src/syntax/process/compile_expressions.ghul index 8d735753e..68b5ee52a 100644 --- a/src/syntax/process/compile_expressions.ghul +++ b/src/syntax/process/compile_expressions.ghul @@ -765,8 +765,6 @@ namespace Syntax.Process is if implied_argument_type? /\ !implied_argument_type.is_type_variable then argument_types.add(implied_argument_type); - a.try_set_constraint(implied_argument_type, "{{0}} is not compatible with {{1}}"); - symbol.set_type(implied_argument_type); else _logger.error(a.location, "cannot infer type here"); @@ -1353,6 +1351,8 @@ namespace Syntax.Process is // ensure any error messages are committed a.walk(self); fi + + arguments[index] = a.value; od overload_result = _overload_resolver.resolve(location, function_group, argument_types, false, true, true); @@ -2649,6 +2649,8 @@ namespace Syntax.Process is // ensure any error messages are committed a.walk(self); fi + + arguments[index] = a.value; od overload_result = _overload_resolver.resolve(call.arguments.location, function_group, argument_types, false, want_instance, false);