From 82f291e5afdd085e9bf0f804eccd9d1d3d825b06 Mon Sep 17 00:00:00 2001 From: agra Date: Thu, 28 May 2026 12:17:49 +0300 Subject: [PATCH] =?UTF-8?q?ffi=20M5.A.next.4B.A:=20compile=5Ferror=20intri?= =?UTF-8?q?nsic=20=E2=80=94=20expected-failing=20lock-in?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `compile_error(msg)` raises a build-time diagnostic at the call site with `msg` as the error text. The arg must be a string literal — runtime expressions can't be reported as compile errors. Used by builder fns to reject malformed pack shapes / arg combinations cleanly instead of silently emitting wrong code. Today: `unresolved 'compile_error'`. Expected (post-fix): focused diagnostic with the literal message at the call site's span. The next commit adds the lowering arm. --- examples/187-compile-error.sx | 14 ++++++++++++++ tests/expected/187-compile-error.exit | 1 + tests/expected/187-compile-error.txt | 1 + 3 files changed, 16 insertions(+) create mode 100644 examples/187-compile-error.sx create mode 100644 tests/expected/187-compile-error.exit create mode 100644 tests/expected/187-compile-error.txt diff --git a/examples/187-compile-error.sx b/examples/187-compile-error.sx new file mode 100644 index 0000000..722bc12 --- /dev/null +++ b/examples/187-compile-error.sx @@ -0,0 +1,14 @@ +// `compile_error(msg)` raises a build-time diagnostic at the call +// site. Used by builder fns (e.g. `#insert build_block_convert(...)`) +// to reject malformed pack shapes with a clear message rather than +// silently producing wrong code. +// +// The diagnostic appears at the source position of the +// `compile_error` call. Argument must be a string literal — runtime +// expressions can't be reported as compile errors. + +#import "modules/std.sx"; + +#run compile_error("intentional compile error from #run"); + +main :: () { } diff --git a/tests/expected/187-compile-error.exit b/tests/expected/187-compile-error.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/expected/187-compile-error.exit @@ -0,0 +1 @@ +1 diff --git a/tests/expected/187-compile-error.txt b/tests/expected/187-compile-error.txt new file mode 100644 index 0000000..2082ca2 --- /dev/null +++ b/tests/expected/187-compile-error.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/187-compile-error.sx:12:6: error: intentional compile error from #run