Skip to content

Fix: Visibility Checks#797

Open
badermarouan wants to merge 2 commits intomainfrom
feature/add-missing-checks-for-member-visibility-struct-field-functions-from-imported-namespaces-enum-cases-etc
Open

Fix: Visibility Checks#797
badermarouan wants to merge 2 commits intomainfrom
feature/add-missing-checks-for-member-visibility-struct-field-functions-from-imported-namespaces-enum-cases-etc

Conversation

@badermarouan
Copy link
Contributor

Fix #681

@badermarouan badermarouan self-assigned this Dec 12, 2025
@badermarouan badermarouan added the sema Semantic Analysis — includes Constraint System & Scope resolution label Dec 12, 2025
@Snowy1803 Snowy1803 changed the title feat: add-missing-checks-for-member-visibility-struct-field-functions-from-imported-namespaces-enum-cases-etc Fix: Visibility Checks Dec 12, 2025
Copy link
Member

@LindonAliu LindonAliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some tests for public or private items into struct and enum pls ?

@badermarouan badermarouan force-pushed the feature/add-missing-checks-for-member-visibility-struct-field-functions-from-imported-namespaces-enum-cases-etc branch from 721e6ae to 4f10a19 Compare December 19, 2025 09:33
node = node->getParent();
}
return llvm::cast<ModuleDecl>(node);
return llvm::dyn_cast<ModuleDecl>(node);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're not supposed to call getModule on a node that isn't in the AST. all nodes in the AST have a module at the top level.

llvm::Twine("Cannot access private field '") + memberName
+ "' of struct '" + structType->getName() + "'"
);
return ConstraintResult::Failed;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are within the constraint system, so this function will be called multiple times if there are multiple overloads within the statement.
So either:

  • Put the diagnostic in a semantic pass, don't fail the CS here
  • Fail the CS, put the diagnostic in the error recovery part of the CS

llvm::SmallVector<Constraint *, 4> constraints;

// Check if access is through a namespace (like a::f)
bool isNamespaceAccess = !node->getIdentifiers().components.empty();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check seems useless

isAllocated: Bool
public data: *Char,
public length: Int,
public isAllocated: Bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these shouldn't really be public. It should be internal to the string.glu file (there is not really a reason anymore to have separate string.glu and stringType.glu)

@badermarouan badermarouan force-pushed the feature/add-missing-checks-for-member-visibility-struct-field-functions-from-imported-namespaces-enum-cases-etc branch from 4f10a19 to e54821e Compare January 8, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sema Semantic Analysis — includes Constraint System & Scope resolution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add missing checks for member visibility (struct field, functions from imported namespaces, enum cases, etc.)

3 participants