Skip to content

Commit

Permalink
try skipping use-before-init for fields
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmad Rezaii <[email protected]>
  • Loading branch information
arezaii committed Jan 8, 2025
1 parent 3e46ac5 commit 6642d82
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/lib/resolution/Resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3135,7 +3135,14 @@ checkForErrorUseBeforeDefine(Context* context, const AstNode* node,
if (node->id().symbolPath() == target.symbolPath()) {
if (target.postOrderId() > node->id().postOrderId()) {
// resolved to an identifier defined later
CHPL_REPORT(context, UseOfLaterVariable, node, target);
// check if this is a field that is not initialized?
if (parsing::idIsField(context, target)) {
// skip for now and let prod handle
return false;
//CHPL_REPORT(context, FieldUsedBeforeInitialized, node, target);
} else {
CHPL_REPORT(context, UseOfLaterVariable, node, target);
}
return true;
}
}
Expand Down Expand Up @@ -3223,7 +3230,7 @@ checkForIdentifierTargetErrorsQuery(Context* context, ID nodeId, ID targetId) {
// Use bitwise-OR here to avoid short-circuiting.
ret |= checkForErrorModuleAsVariable(context, nodeAst, targetId);
ret |= checkForErrorNestedClassFieldRef(context, nodeAst, targetId);
ret |= checkForErrorUseBeforeDefine(context, nodeAst, targetId);
ret |= checkForErrorUseBeforeDefine(context, nodeAst, targetId);

return QUERY_END(ret);
}
Expand Down

0 comments on commit 6642d82

Please sign in to comment.