implements PR-O1.3
This commit is contained in:
+25
@@ -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 = """
|
||||
|
||||
Reference in New Issue
Block a user