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