ffi M5.A.next.4B.A: compile_error intrinsic — expected-failing lock-in
`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.
This commit is contained in:
14
examples/187-compile-error.sx
Normal file
14
examples/187-compile-error.sx
Normal file
@@ -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 :: () { }
|
||||
1
tests/expected/187-compile-error.exit
Normal file
1
tests/expected/187-compile-error.exit
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
1
tests/expected/187-compile-error.txt
Normal file
1
tests/expected/187-compile-error.txt
Normal file
@@ -0,0 +1 @@
|
||||
/Users/agra/projects/sx/examples/187-compile-error.sx:12:6: error: intentional compile error from #run
|
||||
Reference in New Issue
Block a user