diff --git a/es2panda/test/parser/concurrent/using-const-lexical-variable-4-expected.txt b/es2panda/test/parser/concurrent/using-const-lexical-variable-4-expected.txt index 6565cc7a6526e95d920e194e4413baa4ee9a27d9..296459a6acf0e4e6b07f5451e8dc4364800883a3 100644 --- a/es2panda/test/parser/concurrent/using-const-lexical-variable-4-expected.txt +++ b/es2panda/test/parser/concurrent/using-const-lexical-variable-4-expected.txt @@ -1,2 +1,2 @@ -Error: Concurrent function should only use import variable or local variable [using-const-lexical-variable-4.js:20:11] +Error: Concurrent function should only use import variable or local variable, 'a' is not one of them [using-const-lexical-variable-4.js:20:11] the size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-1-expected.txt b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-1-expected.txt index df76adeac5bd985beaa5641d2b61415861a49d4a..5ceb272d0e8aaed854b7c0fe2627e763bd2d2449 100644 --- a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-1-expected.txt +++ b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-1-expected.txt @@ -1,2 +1,2 @@ -Error: Concurrent function should only use import variable or local variable [using-mutable-lexical-variable-1.js:20:11] +Error: Concurrent function should only use import variable or local variable, 'a' is not one of them [using-mutable-lexical-variable-1.js:20:11] the size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-2-expected.txt b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-2-expected.txt index 741aa1119718aeef6486ffc9f783792dfede5924..31e320a2fead702fa4d1114844c865d69f3de93c 100644 --- a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-2-expected.txt +++ b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-2-expected.txt @@ -1,2 +1,2 @@ -Error: Concurrent function should only use import variable or local variable [using-mutable-lexical-variable-2.js:20:11] +Error: Concurrent function should only use import variable or local variable, 'a' is not one of them [using-mutable-lexical-variable-2.js:20:11] the size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-3-expected.txt b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-3-expected.txt index 015a6b4ab98ce0dfe2a05286e11e8779527cd03d..40d3e6e3a5541389e4222e7e6acb1681dd01bc0d 100644 --- a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-3-expected.txt +++ b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-3-expected.txt @@ -1,2 +1,2 @@ -Error: Concurrent function should only use import variable or local variable [using-mutable-lexical-variable-3.js:20:11] +Error: Concurrent function should only use import variable or local variable, 'a' is not one of them [using-mutable-lexical-variable-3.js:20:11] the size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-4-expected.txt b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-4-expected.txt index 80b0902093bfb278a33c66afe4c4fb4d0f969bf7..feac12bee69d46987e1f9440412fba2c22545575 100644 --- a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-4-expected.txt +++ b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-4-expected.txt @@ -1,2 +1,2 @@ -Error: Concurrent function should only use import variable or local variable [using-mutable-lexical-variable-4.js:21:15] +Error: Concurrent function should only use import variable or local variable, 'a' is not one of them [using-mutable-lexical-variable-4.js:21:15] the size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-5-expected.txt b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-5-expected.txt index c07b60b0478655e0679659434ee83fc5f5dbcb22..cf2d433fbd8814d6243d2e05af98a173b11870d6 100644 --- a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-5-expected.txt +++ b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-5-expected.txt @@ -1,2 +1,2 @@ -Error: Concurrent function should only use import variable or local variable [using-mutable-lexical-variable-5.js:20:11] +Error: Concurrent function should only use import variable or local variable, 'a' is not one of them [using-mutable-lexical-variable-5.js:20:11] the size of programs is expected to be 1, but is 0 diff --git a/es2panda/util/concurrent.cpp b/es2panda/util/concurrent.cpp index 058fecbeb131345d6bab5025a46fc1b3a84d9199..2090f6af028a1c227578076eb8011a03ab1662bc 100644 --- a/es2panda/util/concurrent.cpp +++ b/es2panda/util/concurrent.cpp @@ -38,7 +38,7 @@ void Concurrent::SetConcurrent(ir::ScriptFunction *func, const ir::AstNode * nod } void Concurrent::ThrowInvalidConcurrentFunction(const lexer::LineIndex &lineIndex, const ir::AstNode *expr, - ConcurrentInvalidFlag errFlag) + ConcurrentInvalidFlag errFlag, util::StringView varName) { auto line = expr->Range().start.line; auto column = (const_cast(lineIndex)).GetLocation(expr->Range().start).col - 1; @@ -49,8 +49,10 @@ void Concurrent::ThrowInvalidConcurrentFunction(const lexer::LineIndex &lineInde break; } case ConcurrentInvalidFlag::NOT_IMPORT_VARIABLE: { - throw Error {ErrorType::GENERIC, "Concurrent function should only use import variable or local variable", - line, column}; + std::stringstream ss; + ss << "Concurrent function should only use import variable or local variable, '" << varName + << "' is not one of them"; + throw Error {ErrorType::GENERIC, ss.str(), line, column}; break; } default: @@ -69,7 +71,8 @@ void Concurrent::VerifyImportVarForConcurrentFunction(const lexer::LineIndex &li return; } - ThrowInvalidConcurrentFunction(lineIndex, node, ConcurrentInvalidFlag::NOT_IMPORT_VARIABLE); + ThrowInvalidConcurrentFunction(lineIndex, node, ConcurrentInvalidFlag::NOT_IMPORT_VARIABLE, + result.variable->Declaration()->Name()); } } // namespace panda::es2panda::util \ No newline at end of file diff --git a/es2panda/util/concurrent.h b/es2panda/util/concurrent.h index 633d65461706d5e654f0981e5a58ec78419ac20b..ae718dcabbb44f28db99d4b4b2a98aa524a4c27d 100644 --- a/es2panda/util/concurrent.h +++ b/es2panda/util/concurrent.h @@ -49,7 +49,7 @@ public: static void SetConcurrent(ir::ScriptFunction *func, const ir::AstNode *node, const lexer::LineIndex &lineIndex); static void ThrowInvalidConcurrentFunction(const lexer::LineIndex &lineIndex, const ir::AstNode *expr, - ConcurrentInvalidFlag errFlag); + ConcurrentInvalidFlag errFlag, util::StringView varName = ""); static void VerifyImportVarForConcurrentFunction(const lexer::LineIndex &lineIndex, const ir::AstNode *node, const binder::ScopeFindResult &result); };