From 4528889ae3ef32abcc33e05c1d940ea2f3499a1a Mon Sep 17 00:00:00 2001 From: Bijan Naimi <30612689+branai@users.noreply.github.com> Date: Mon, 26 Dec 2022 19:03:45 -0800 Subject: [PATCH] simpler fix for eval whitespaces --- vm/src/stdlib/builtins.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/vm/src/stdlib/builtins.rs b/vm/src/stdlib/builtins.rs index 6380c2343..446a197a7 100644 --- a/vm/src/stdlib/builtins.rs +++ b/vm/src/stdlib/builtins.rs @@ -256,15 +256,6 @@ mod builtins { )); } - // Check for newlines, tabs, or whitespaces at start - let wsp_arr = [9, 10, 32]; - let mut i = 0; - while i < source.len() && wsp_arr.contains(&source[i]) { - i = i + 1; - } - // Slice off whitespaces - let source = &source[i..source.len()]; - let source = std::str::from_utf8(source).map_err(|err| { let msg = format!( "(unicode error) 'utf-8' codec can't decode byte 0x{:x?} in position {}: invalid start byte", @@ -274,7 +265,7 @@ mod builtins { vm.new_exception_msg(vm.ctx.exceptions.syntax_error.to_owned(), msg) })?; - Ok(Either::A(vm.ctx.new_str(source))) + Ok(Either::A(vm.ctx.new_str(source.trim_start()))) } Either::B(code) => Ok(Either::B(code)), }?;