XO1001: std/sys/<os> used outside the matching target arm
Platform specific APIs live in std/sys/<os> and may be referenced only inside the arm of a match target.os for that OS, so code for one platform cannot leak into another’s build while every arm is still type checked on every host. The prototype does not emit this code yet: no std/sys/<os> modules exist, and the example below names a hypothetical std/sys/linux function. See core 12.2.
Example
use std/sys/linux
pub fn page_size() -> Int {
linux.page_size()
}Fix
use std/sys/linux
pub fn page_size() -> Int {
match target.os {
Linux => linux.page_size()
Darwin => 16384
Windows => 4096
Wasi => 65536
}
}Run xo explain XO1001 for this text in a terminal, or see
section 10.6 of the specification.