From 63b5b6416c6bde16560eb9b83a9e3122599369d5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 14 Oct 2022 16:06:35 +0300 Subject: Fix 'for [] x: ...' to treat as value attributes --- libbuild2/test/script/parser+for.test.testscript | 19 ++++++++++--------- libbuild2/test/script/parser.cxx | 11 +++++------ 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'libbuild2/test/script') diff --git a/libbuild2/test/script/parser+for.test.testscript b/libbuild2/test/script/parser+for.test.testscript index 426a39b..9d70886 100644 --- a/libbuild2/test/script/parser+for.test.testscript +++ b/libbuild2/test/script/parser+for.test.testscript @@ -58,7 +58,7 @@ cmd b EOO - : typed-value + : typed-values : $* <>~%EOO% for x: [dir_paths] a b @@ -69,7 +69,7 @@ %cmd (b/|'b\\')% EOO - : typed-var + : typed-var-value : $* <>~%EOO% for [dir_path] x: a b @@ -80,15 +80,16 @@ %cmd (b/|'b\\')% EOO - : type-mismatch + : typed-values-var-value : - $* <>EOE != 0 - for [string] x: [dir_paths] a b + $* <>~%EOO% + for [dir_path] x: [strings] a b cmd $x end EOI - testscript:1:1: error: conflicting variable x type string and value type dir_path - EOE + %cmd (a/|'a\\')% + %cmd (b/|'b\\')% + EOO : scope-var : @@ -471,7 +472,7 @@ echo a b | for x EOO - : typed-var + : typed-var-value : $* <>EOO echo 'a b' | for -w [dir_path] x @@ -821,7 +822,7 @@ for x b >EOO for -w [dir_path] x <'a b' diff --git a/libbuild2/test/script/parser.cxx b/libbuild2/test/script/parser.cxx index f85b185..a30f666 100644 --- a/libbuild2/test/script/parser.cxx +++ b/libbuild2/test/script/parser.cxx @@ -1666,15 +1666,14 @@ namespace build2 auto exec_for = [this] (const variable& var, value&& val, - const location& l) + const attributes& val_attrs, + const location&) { value& lhs (scope_->assign (var)); - // To match the function semantics also pass the value's type - // attribute, restoring it from RHS. Note that the value can't be - // NULL. - // - apply_value (&var, lhs, move (val), type::assign, l, val.type); + attributes_.push_back (val_attrs); + + apply_value_attributes (&var, lhs, move (val), type::assign); if (script_->test_command_var (var.name)) scope_->reset_special (); -- cgit v1.1