From 552d4b7141476e7cb700386278bd921e29004e8d Mon Sep 17 00:00:00 2001 From: vms Date: Sun, 8 Nov 2020 19:36:33 +0300 Subject: [PATCH] fix : parsing in record fields --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/decoders/wat.rs | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2908fee..cddac33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,7 +161,7 @@ checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" [[package]] name = "wasmer-interface-types-fl" -version = "0.17.16" +version = "0.17.17" dependencies = [ "log", "nom", diff --git a/Cargo.toml b/Cargo.toml index 7f2accb..2348578 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasmer-interface-types-fl" -version = "0.17.16" +version = "0.17.17" description = "WebAssembly Interface Types library for Wasmer" license = "MIT" authors = ["The Wasmer Engineering Team "] diff --git a/src/decoders/wat.rs b/src/decoders/wat.rs index ac0c1ca..98fb16c 100644 --- a/src/decoders/wat.rs +++ b/src/decoders/wat.rs @@ -184,9 +184,21 @@ impl Parse<'_> for RecordType { })? .to_string(); + if !name.ends_with(':') { + parser.step(|cursor| { + if let Some((":", rest)) = cursor.reserved() { + return Ok(("", rest)); + } + Err(cursor.error("expected : between an argument and a type")) + })?; + } + let ty = parser.parse()?; - fields.push(RecordFieldType { name, ty }); + fields.push(RecordFieldType { + name: name.trim_end_matches(":").to_string(), + ty, + }); } Ok(()) })?;