feat: try/unwrap payload types, LSP format, macro paste, freestanding runtime
ci / build (ubuntu) (push) Has been cancelled
ci / unit + fmt (push) Has been cancelled
ci / examples (push) Has been cancelled
ci / goldens + tools (push) Has been cancelled
ci / apps (push) Has been cancelled
ci / selfhost smoke (push) Has been cancelled
ci / macos smoke (push) Has been cancelled
ci / windows smoke (push) Has been cancelled
ci / CI gate (push) Has been cancelled
selfhost-loop / bootstrap determinism (push) Has been cancelled
ci / build (ubuntu) (push) Has been cancelled
ci / unit + fmt (push) Has been cancelled
ci / examples (push) Has been cancelled
ci / goldens + tools (push) Has been cancelled
ci / apps (push) Has been cancelled
ci / selfhost smoke (push) Has been cancelled
ci / macos smoke (push) Has been cancelled
ci / windows smoke (push) Has been cancelled
ci / CI gate (push) Has been cancelled
selfhost-loop / bootstrap determinism (push) Has been cancelled
- Type `?`/`!` as Result/Option Ok payload (not always int); fix unwrap C types - LSP 0.18 document formatting (bux fmt) + VS Code format-on-save - Macro `:type` generics (Array_New<$t>) and operators-only tt paste - Ship runtime_freestanding.c + BUX_RUNTIME=freestanding + smokes/examples
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// Try operator `?` with generic Result<T,E> (non-int Ok payload).
|
||||
import Std::Io::{PrintLine};
|
||||
import Std::Result::{Result, Result_NewOk, Result_NewErr};
|
||||
import Std::String::{String_Eq};
|
||||
|
||||
func GetGreeting(name: String) -> Result<String, String> {
|
||||
if String_Eq(name, "") {
|
||||
return Result_NewErr<String, String>("empty name");
|
||||
}
|
||||
return Result_NewOk<String, String>("hello");
|
||||
}
|
||||
|
||||
func Greet(name: String) -> Result<String, String> {
|
||||
let g: String = GetGreeting(name)?;
|
||||
return Result_NewOk<String, String>(g);
|
||||
}
|
||||
|
||||
func Main() -> int {
|
||||
PrintLine("Try generic Result demo:");
|
||||
|
||||
let ok: Result<String, String> = Greet("bux");
|
||||
if ok.tag == Result_Ok {
|
||||
PrintLine(ok.data.Ok_0);
|
||||
}
|
||||
|
||||
let err: Result<String, String> = Greet("");
|
||||
if err.tag == Result_Err {
|
||||
PrintLine(err.data.Err_0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user