From d62a253762dd6f525cd2a5f3f88172a01d0ec1dd Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 6 Jul 2022 09:12:46 +0200 Subject: [PATCH] Allow null operands to string.eq Fixes #18. --- proposals/stringref/Overview.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/proposals/stringref/Overview.md b/proposals/stringref/Overview.md index 39b00f5..5a00935 100644 --- a/proposals/stringref/Overview.md +++ b/proposals/stringref/Overview.md @@ -195,6 +195,10 @@ address ::= i32 | i64 Such instructions also take the memory to which to read or write as an immediate. +Although `stringref` is a nullable type, trap if a null `stringref` +value reaches any instruction in this proposal. The one exception is +`string.eq`. + ### Creating strings ``` @@ -344,8 +348,9 @@ If an allocation fails, the implementation must trap. Fallible ``` (string.eq a:stringref b:stringref) -> i32 ``` -Return 1 if the strings *`a`* and *`b`* contain the same codepoint -sequence. Return 0 otherwise. +If both *`a`* and *`b`* are null, return 1. If only one of them is +null, return 0. Otherwise return 1 if the strings *`a`* and *`b`* +contain the same codepoint sequence, or 0 otherwise. ``` (string.is_usv_sequence str:stringref)