MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / user_written_external_function_still_warns

Function user_written_external_function_still_warns

src/compilation_pipeline.rs:1904–1927  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1902export impl Rect {
1903 area: (self: Rect*) -> i32 { return self.width * self.height }
1904}
1905"#;
1906 let mut pipeline = CompilationPipeline::new();
1907 pipeline.set_write_artifacts(false);
1908 pipeline.set_module_resolver(Some(Box::new(move |name: &str| {
1909 (name == "geometry").then(|| provider.to_owned())
1910 })));
1911
1912 let importer = r#"
1913geometry := import("geometry")
1914measure: <T: geometry.Measurable>(value: T*) -> i32 { return value.area() }
1915main: () -> i32 {
1916 rect: geometry.Rect = { .width = 6, .height = 7 }
1917 return measure<geometry.Rect>(&rect)
1918}
1919"#;
1920 pipeline
1921 .compile_program_closure("main", importer)
1922 .expect("qualified imported interface bound should compile");
1923 }
1924
1925 #[test]
1926 fn imported_bounded_struct_preserves_its_interface_contract() {
1927 let provider = r#"
1928export interface Measurable {
1929 area: (self: Self*) -> i32
1930}

Callers

nothing calls this directly

Calls 2

set_write_artifactsMethod · 0.80
compileMethod · 0.45

Tested by

no test coverage detected