implements PR-039

This commit is contained in:
2026-03-24 13:42:25 +00:00
parent 0728637f58
commit 4e2cad60cb
3 changed files with 301 additions and 3 deletions
@@ -72,6 +72,32 @@ class PbsFrontendCompilerTest {
assertEquals(2, fileBackend.functions().size());
}
@Test
void shouldLowerExecutableFunctionsWithCallsiteCategories() {
final var source = """
fn b(x: int) -> int {
return x;
}
fn a() -> int {
return b(1);
}
""";
final var diagnostics = DiagnosticSink.empty();
final var compiler = new PbsFrontendCompiler();
final var fileBackend = compiler.compileFile(new FileId(42), source, diagnostics);
assertTrue(diagnostics.isEmpty(), "Valid program should not report diagnostics");
assertEquals(2, fileBackend.executableFunctions().size());
final var executableA = fileBackend.executableFunctions().stream()
.filter(fn -> fn.callableName().equals("a"))
.findFirst()
.orElseThrow();
assertTrue(executableA.instructions().stream().anyMatch(i ->
i.kind() == p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.CALL_FUNC));
}
@Test
void shouldNotLowerWhenSyntaxErrorsExist() {
final var source = """