Skip to content

Commit c50822c

Browse files
authored
declare world-level type exports before function imports (#135)
This avoids a declaration ordering issue if an imported function refers to an exported type (e.g. as a parameter or result type). Fixes #134 Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent 3b5ef2e commit c50822c

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/summary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1986,8 +1986,8 @@ from ..types import Result, Ok, Err, Some
19861986
"{docs}{python_imports}
19871987
from .types import Result, Ok, Err, Some
19881988
{imports}
1989-
{function_imports}
19901989
{type_exports}
1990+
{function_imports}
19911991
{protocol}
19921992
"
19931993
)?;

src/test/tests.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ pub struct ThingList(Vec<u8>);
5757
pub struct ThingString(String);
5858
pub struct MyFloat(f64);
5959

60+
#[async_trait]
61+
impl TestsImports for Ctx {
62+
async fn output(&mut self, _: Frame) -> Result<()> {
63+
unreachable!()
64+
}
65+
}
66+
6067
macro_rules! load_guest_code {
6168
($($input_string:expr),*) => {
6269
&[

src/test/wit/tests.wit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,10 @@ world tests {
179179
export add: func(a: borrow<float>, b: borrow<float>) -> own<float>;
180180

181181
export read-file: func(path: string) -> result<list<u8>, string>;
182+
183+
record frame {
184+
id: s32,
185+
}
186+
187+
import output: func(frame: frame);
182188
}

0 commit comments

Comments
 (0)