diff --git a/.github/workflows/d.yml b/.github/workflows/d.yml index f5597b1e..48f87755 100644 --- a/.github/workflows/d.yml +++ b/.github/workflows/d.yml @@ -419,8 +419,10 @@ jobs: run: | ./tlang compile source/tlang/testing/simple_function_recursion_factorial.t ./tlang.out - - + - name: Simple function (statement-level) + run: | + ./tlang compile source/tlang/testing/simple_func_statement.t + ./tlang.out # TODO: Re-enable when we support the `discard` keyword again #- name: Simple variables diff --git a/source/tlang/compiler/core.d b/source/tlang/compiler/core.d index eba1109b..7319112c 100644 --- a/source/tlang/compiler/core.d +++ b/source/tlang/compiler/core.d @@ -418,6 +418,8 @@ unittest "source/tlang/testing/simple_pointer_array_syntax.t", + + "source/tlang/testing/simple_func_statement.t" ]; foreach(string testFile; testFiles) { diff --git a/source/tlang/compiler/symbols/data.d b/source/tlang/compiler/symbols/data.d index 7388fba0..57938dd7 100644 --- a/source/tlang/compiler/symbols/data.d +++ b/source/tlang/compiler/symbols/data.d @@ -1035,6 +1035,9 @@ public final class FunctionCall : Call, MStatementSearchable, MStatementReplacea { super(functionName); this.arguments = arguments; + + /* Weighted as 2 */ + weight = 2; } public override string toString() diff --git a/source/tlang/testing/simple_func_statement.t b/source/tlang/testing/simple_func_statement.t new file mode 100644 index 00000000..a91e449d --- /dev/null +++ b/source/tlang/testing/simple_func_statement.t @@ -0,0 +1,14 @@ +module simple_func_statement; + +void k(int* p) +{ + +} + +int main() +{ + int* arr; + k(arr); + + return 0; +}