From d270cf0b17f377e4b2cdfb6b85d5ac2698ff8e11 Mon Sep 17 00:00:00 2001 From: zhangyouyou Date: Mon, 28 Oct 2024 17:00:09 +0800 Subject: [PATCH] chmod number and string should be shared types Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IB0ACU Description:Sharemodule chmod number and string should be shared types Signed-off-by: zhangyouyou --- ecmascript/module/js_module_source_text.cpp | 8 ++++---- test/moduletest/shareduse/expect_output.txt | 4 +++- test/moduletest/shareduse/shareduse.ts | 10 ++++++---- test/moduletest/shareduse/string.ts | 5 +++++ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ecmascript/module/js_module_source_text.cpp b/ecmascript/module/js_module_source_text.cpp index be36fbc029..f14ad8b249 100644 --- a/ecmascript/module/js_module_source_text.cpp +++ b/ecmascript/module/js_module_source_text.cpp @@ -1456,8 +1456,8 @@ JSTaggedValue SourceTextModule::FindByExport(const JSTaggedValue &exportEntriesT void SourceTextModule::StoreModuleValue(JSThread *thread, int32_t index, const JSHandle &value) { JSHandle module(thread, this); - if (UNLIKELY(IsSharedModule(module)) && !value->IsJSShared()) { - CString msg = "Export non-shared object form shared-module, module name is :" + + if (UNLIKELY(IsSharedModule(module)) && !value->IsSharedType()) { + CString msg = "Export non-shared object from shared-module, module name is :" + module->GetEcmaModuleRecordNameString(); THROW_ERROR(thread, ErrorType::SYNTAX_ERROR, msg.c_str()); } @@ -1486,8 +1486,8 @@ void SourceTextModule::StoreModuleValue(JSThread *thread, const JSHandle &value) { JSHandle module(thread, this); - if (UNLIKELY(IsSharedModule(module)) && !value->IsJSShared()) { - CString msg = "Export non-shared object form shared-module, module name is :" + + if (UNLIKELY(IsSharedModule(module)) && !value->IsSharedType()) { + CString msg = "Export non-shared object from shared-module, module name is :" + module->GetEcmaModuleRecordNameString(); THROW_ERROR(thread, ErrorType::SYNTAX_ERROR, msg.c_str()); } diff --git a/test/moduletest/shareduse/expect_output.txt b/test/moduletest/shareduse/expect_output.txt index d8f859fec7..f614c49f4d 100644 --- a/test/moduletest/shareduse/expect_output.txt +++ b/test/moduletest/shareduse/expect_output.txt @@ -12,4 +12,6 @@ # limitations under the License. A -SyntaxError: Export non-shared object form shared-module, module name is :func +100 +false +SyntaxError: Export non-shared object from shared-module, module name is :func diff --git a/test/moduletest/shareduse/shareduse.ts b/test/moduletest/shareduse/shareduse.ts index adf81b8ef2..580b05a0c0 100644 --- a/test/moduletest/shareduse/shareduse.ts +++ b/test/moduletest/shareduse/shareduse.ts @@ -23,7 +23,7 @@ // @ts-nocheck declare function print(str: any): string; -import {foo} from "./string" +import {strA, strB, numberC, booleanD,foo} from "./string" "use shared" export class A { @@ -33,11 +33,13 @@ export class A { } } -new A() - +new A(); +print(numberC); +print(booleanD); import('./func').then(ns => { print(ns.h); }).then().catch((err) => { print(err); } -) \ No newline at end of file +) + diff --git a/test/moduletest/shareduse/string.ts b/test/moduletest/shareduse/string.ts index 6119e59a18..e48b87e52a 100644 --- a/test/moduletest/shareduse/string.ts +++ b/test/moduletest/shareduse/string.ts @@ -22,6 +22,11 @@ // @ts-nocheck declare function print(str: any): string; +"use shared" +export var strA : string = "(This is strA!)"; +export var strB : string = "(This is strB!)"; +export var numberC : number = 100; +export var booleanD : bool = false; export function foo() { 'use sendable' print("foo");