implements PR-O1.3

This commit is contained in:
2026-03-24 13:42:26 +00:00
parent 9e3d9ccb93
commit 3e14c13979
3 changed files with 53 additions and 3 deletions
@@ -98,6 +98,31 @@ class PbsFrontendCompilerTest {
i.kind() == p.studio.compiler.models.IRBackendExecutableFunction.InstructionKind.CALL_FUNC));
}
@Test
void shouldLowerExecutableCallsitesInDeterministicSourceOrder() {
final var source = """
fn b() -> int { return 1; }
fn c() -> int { return 2; }
fn a() -> int {
b();
c();
return 0;
}
""";
final var diagnostics = DiagnosticSink.empty();
final var compiler = new PbsFrontendCompiler();
final var fileBackend = compiler.compileFile(new FileId(99), source, diagnostics);
assertTrue(diagnostics.isEmpty(), "Valid program should not report diagnostics");
final var executableA = fileBackend.executableFunctions().stream()
.filter(fn -> fn.callableName().equals("a"))
.findFirst()
.orElseThrow();
assertEquals("b", executableA.instructions().get(0).calleeCallableName());
assertEquals("c", executableA.instructions().get(1).calleeCallableName());
}
@Test
void shouldNotLowerWhenSyntaxErrorsExist() {
final var source = """