From 7f7b89b4cfeffec5f80c59856730a1f62880b67c Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Fri, 10 Jun 2022 15:46:19 -0700 Subject: [PATCH 1/3] Update grammar for `func` in `WIT.md` --- WIT.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WIT.md b/WIT.md index 0eaca7f5a..893f3d1fe 100644 --- a/WIT.md +++ b/WIT.md @@ -368,7 +368,7 @@ union-cases ::= ty, | ty ',' union-cases? ``` -## Item: `function` +## Item: `func` Functions can also be defined in a `*.wit` document. Functions have a name, parameters, and results. Functions can optionally also be declared as `async` @@ -383,7 +383,7 @@ sleep: async func(ms: u64) Specifically functions have the structure: ```wit -func-item ::= id ':' 'async'? 'function' '(' func-args ')' func-ret +func-item ::= id ':' 'async'? 'func' '(' func-args ')' func-ret func-args ::= func-arg | func-arg ',' func-args? From 699e6e2ae21c2dfaa41e97259b4b1a098d37de83 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Fri, 10 Jun 2022 16:00:30 -0700 Subject: [PATCH 2/3] Also change the bindgen demo to use `func` instead of `function`. --- crates/wit-bindgen-demo/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wit-bindgen-demo/index.html b/crates/wit-bindgen-demo/index.html index f30d318c7..de9383436 100644 --- a/crates/wit-bindgen-demo/index.html +++ b/crates/wit-bindgen-demo/index.html @@ -39,7 +39,7 @@

Input *.wit

name: string, age: u32, } -hello: function(who: person) -> string +hello: func(who: person) -> string
From da73243ef4caffade77771249b00522857fe8b56 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Fri, 10 Jun 2022 16:20:41 -0700 Subject: [PATCH 3/3] Update parser error message from `fn` to `func`. --- crates/parser/src/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/parser/src/ast.rs b/crates/parser/src/ast.rs index 9276e0c02..0e58d43bf 100644 --- a/crates/parser/src/ast.rs +++ b/crates/parser/src/ast.rs @@ -222,7 +222,7 @@ impl<'a> Item<'a> { Some((_span, Token::Id)) | Some((_span, Token::ExplicitId)) => { Value::parse(tokens, docs).map(Item::Value) } - other => Err(err_expected(tokens, "`type`, `resource`, or `fn`", other).into()), + other => Err(err_expected(tokens, "`type`, `resource`, or `func`", other).into()), } } }