From 4c670e66f38358480b2906cb0e4ceb779fac1435 Mon Sep 17 00:00:00 2001 From: agra Date: Wed, 20 May 2026 09:12:57 +0300 Subject: [PATCH] ffi 2.0: xfail parser test for `Foo :: #jni_class(...) { ... }` Today's parser doesn't recognize #jni_class as a hash directive after `::`, so it falls through to expression parsing and errors at the `#` token. Step 2.1 extends parseConstBinding to accept the directive (opaque on empty body) and re-snapshots this file to green. --- examples/ffi-jni-class-01-empty.sx | 18 ++++++++++++++++++ tests/expected/ffi-jni-class-01-empty.exit | 1 + tests/expected/ffi-jni-class-01-empty.txt | 1 + 3 files changed, 20 insertions(+) create mode 100644 examples/ffi-jni-class-01-empty.sx create mode 100644 tests/expected/ffi-jni-class-01-empty.exit create mode 100644 tests/expected/ffi-jni-class-01-empty.txt diff --git a/examples/ffi-jni-class-01-empty.sx b/examples/ffi-jni-class-01-empty.sx new file mode 100644 index 0000000..2e0f9ea --- /dev/null +++ b/examples/ffi-jni-class-01-empty.sx @@ -0,0 +1,18 @@ +// Phase 2 step 2.0 (PLAN-FFI.md): xfail parser test for the +// type-introducer `Foo :: #jni_class("java/path/Foo") { }` directive. +// +// Today's parser doesn't recognize `#jni_class` as a known hash +// directive after `::`, so it falls through to expression parsing +// and fails at the `#` token. Step 2.1 (next commit) extends +// `parseConstBinding` to accept the directive, treat an empty body +// as an opaque forward declaration, and re-snapshots this file to +// capture the green behavior. + +#import "modules/std.sx"; + +Foo :: #jni_class("java/path/Foo") { } + +main :: () -> s32 { + print("parse-only ok\n"); + 0; +} diff --git a/tests/expected/ffi-jni-class-01-empty.exit b/tests/expected/ffi-jni-class-01-empty.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/expected/ffi-jni-class-01-empty.exit @@ -0,0 +1 @@ +1 diff --git a/tests/expected/ffi-jni-class-01-empty.txt b/tests/expected/ffi-jni-class-01-empty.txt new file mode 100644 index 0000000..85040dc --- /dev/null +++ b/tests/expected/ffi-jni-class-01-empty.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/ffi-jni-class-01-empty.sx:13:8: error: unexpected token in expression