Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dyno: Resolve auto module visibility statements eagerly #26461

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions frontend/test/resolution/testDeprecationUnstable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,26 @@ static std::string debugDeclName = "";

static void testDebuggingBreakpoint() {}

static CompilerFlags warnUnstableFlags() {
static auto flags = []() {
CompilerFlags flags;
flags.set(CompilerFlags::WARN_UNSTABLE, true);
return flags;
}();
return flags;
}

static Context*
turnOnWarnUnstable(Context* ctx) {
CompilerFlags flags;
flags.set(CompilerFlags::WARN_UNSTABLE, true);
setCompilerFlags(ctx, std::move(flags));
assert(isCompilerFlagSet(ctx, CompilerFlags::WARN_UNSTABLE));
return ctx;
buildStdContextWithUnstableWarnings() {
auto context = buildStdContext(warnUnstableFlags());
assert(isCompilerFlagSet(context, CompilerFlags::WARN_UNSTABLE));
return context;
}

static Context* turnOnWarnUnstable(Context* context) {
setCompilerFlags(context, warnUnstableFlags());
assert(isCompilerFlagSet(context, CompilerFlags::WARN_UNSTABLE));
return context;
}

static const AstNode*
Expand Down Expand Up @@ -430,7 +443,7 @@ static void test1(void) {

// Warnings should not be emitted for method receivers.
static void test2(void) {
Context* ctx = turnOnWarnUnstable(buildStdContext());
Context* ctx = buildStdContextWithUnstableWarnings();
ErrorGuard guard(ctx);

auto path = TEST_NAME(ctx);
Expand Down Expand Up @@ -576,7 +589,7 @@ static void test4(ErrorType expectedError) {
? "@unstable"
: "@deprecated";

Context* ctx = turnOnWarnUnstable(buildStdContext());
Context* ctx = buildStdContextWithUnstableWarnings();
ErrorGuard guard(ctx);

auto path = TEST_NAME(ctx);
Expand Down
1 change: 0 additions & 1 deletion frontend/test/resolution/testTypeConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,6 @@ static void testRecursiveTypeConstructorMutual() {
printf("testRecursiveTypeConstructorMutual\n");
Context* context = buildStdContext();
ErrorGuard guard(context);
setupModuleSearchPaths(context, false, false, {}, {});

auto p = parseTypeAndFieldsOfX(context,
R"""(
Expand Down
10 changes: 9 additions & 1 deletion frontend/test/test-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "test-common.h"

#include "chpl/framework/compiler-configuration.h"
#include "chpl/parsing/parsing-queries.h"
#include "chpl/resolution/scope-queries.h"
#include "chpl/uast/post-parse-checks.h"
Expand Down Expand Up @@ -81,7 +82,7 @@ const uast::AstNode* findOnlyNamed(const uast::Module* mod, std::string name) {

static std::unique_ptr<Context> _reusedContext;

chpl::Context* buildStdContext() {
chpl::Context* buildStdContext(chpl::CompilerFlags flags) {
if (_reusedContext.get() == nullptr) {
std::string chpl_home;
if (const char* chpl_home_env = getenv("CHPL_HOME")) {
Expand All @@ -100,6 +101,13 @@ chpl::Context* buildStdContext() {
}

parsing::setupModuleSearchPaths(_reusedContext.get(), false, false, {}, {});
setCompilerFlags(_reusedContext.get(), flags);

// resolve the standard modules from the same "usual" predefined point.
// this way, the order in which the modules are traversed is always the same.
if (auto autoUseScope = resolution::scopeForAutoModule(_reusedContext.get())) {
std::ignore = resolution::resolveVisibilityStmts(_reusedContext.get(), autoUseScope, false);
}

return _reusedContext.get();
}
2 changes: 1 addition & 1 deletion frontend/test/test-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ parseStringAndReportErrors(chpl::parsing::Parser* parser, const char* filename,

const chpl::uast::AstNode* findOnlyNamed(const chpl::uast::Module* mod, std::string name);

chpl::Context* buildStdContext();
chpl::Context* buildStdContext(chpl::CompilerFlags flags = {});

#endif
5 changes: 4 additions & 1 deletion tools/chapel-py/src/method-tables/core-methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ CLASS_BEGIN(Context)

auto& paths = std::get<0>(args);
auto& filenames = std::get<1>(args);
parsing::setupModuleSearchPaths(node, false, false, paths, filenames))
parsing::setupModuleSearchPaths(node, false, false, paths, filenames);
if (auto autoUseScope = resolution::scopeForAutoModule(node)) {
std::ignore = resolution::resolveVisibilityStmts(node, autoUseScope, false);
})
METHOD(Context, is_bundled_path, "Check if the given file path is within the bundled (built-in) Chapel files",
bool(chpl::UniqueString),

Expand Down
Loading