diff --git a/frontend/lib/resolution/prims.cpp b/frontend/lib/resolution/prims.cpp index 3f4fb8b250d..02eed2edf33 100644 --- a/frontend/lib/resolution/prims.cpp +++ b/frontend/lib/resolution/prims.cpp @@ -1766,7 +1766,6 @@ CallResolutionResult resolvePrimCall(ResolutionContext* rc, case PRIM_BLOCK_UNLOCAL: case PRIM_LOGICAL_FOLDER: case PRIM_WIDE_MAKE: - case PRIM_WIDE_GET_LOCALE: case PRIM_REGISTER_GLOBAL_VAR: case PRIM_BROADCAST_GLOBAL_VARS: case PRIM_PRIVATE_BROADCAST: @@ -1791,6 +1790,11 @@ CallResolutionResult resolvePrimCall(ResolutionContext* rc, CHPL_UNIMPL("misc primitives"); break; + case PRIM_WIDE_GET_LOCALE: + type = QualifiedType(QualifiedType::CONST_VAR, + CompositeType::getLocaleIDType(context)); + break; + case PRIM_GATHER_TESTS: type = primGatherTests(context, ci); break; diff --git a/frontend/test/resolution/testResolve.cpp b/frontend/test/resolution/testResolve.cpp index e6a1874b510..0a9b21eb2ae 100644 --- a/frontend/test/resolution/testResolve.cpp +++ b/frontend/test/resolution/testResolve.cpp @@ -1759,6 +1759,30 @@ static void testPromotionPrim() { assert(guard.realizeErrors() == 0); } +// Test the '_wide_get_locale' primitive. +static void testGetLocalePrim() { + Context* context = buildStdContext(); + // TODO: we get a query system infinite recursion without this for some reason + context->collectGarbage(); + ErrorGuard guard(context); + + auto variables = resolveTypesOfVariables(context, + R"""( + var x : real; + var locId = __primitive("_wide_get_locale", x); + var sublocId = chpl_sublocFromLocaleID(locId); + )""", { "locId", "sublocId" }); + + auto locId = variables.at("locId"); + assert(locId.type()); + assert(locId.type() == CompositeType::getLocaleIDType(context)); + auto sublocId = variables.at("sublocId"); + assert(sublocId.type()); + assert(sublocId.type()->isIntType()); + + assert(guard.realizeErrors() == 0); +} + int main() { test1(); test2(); @@ -1791,6 +1815,7 @@ int main() { testInfiniteCycleBug(); testPromotionPrim(); + testGetLocalePrim(); return 0; }