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

Fix compiler crash on xml attribute access on non xml:Element values #42598

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

poorna2152
Copy link
Contributor

@poorna2152 poorna2152 commented Apr 19, 2024

Purpose

Describe the problems, issues, or needs driving this feature/fix and include links to related issues.

Fixes #35191

Approach

Fix xml attribute access on all subtypes of xml

Samples

Remarks

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@poorna2152 poorna2152 added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Apr 19, 2024
Copy link

github-actions bot commented May 4, 2024

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label May 4, 2024
@poorna2152 poorna2152 removed the Stale label May 7, 2024
@@ -8619,6 +8619,9 @@ private BType getLaxFieldAccessType(BType exprType) {
return symTable.jsonType;
case TypeTags.XML:
case TypeTags.XML_ELEMENT:
case TypeTags.XML_COMMENT:
Copy link
Member

Choose a reason for hiding this comment

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

My concern is why we include XML within the getLaxFieldAccessType function. If the type is lax, then the lax field access rules are included. XML is not a lax type, correct?

@@ -314,7 +314,7 @@ public BType checkType(Location pos,
public boolean isLaxFieldAccessAllowed(BType type) {
type = Types.getImpliedType(type);
Set<BType> visited = new HashSet<>();
return isLaxType(type, visited) == 1 || type.tag == TypeTags.XML || type.tag == TypeTags.XML_ELEMENT;
return isLaxType(type, visited) == 1 || isAssignable(type, symTable.xmlType);
Copy link
Member

Choose a reason for hiding this comment

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

In the previous implementation, this was also incorrect. Lax field access should only be allowed for lax types. However, XML is not a lax type. I have concerns about including this logic within this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using xml-attribute-access-expr with built-in subtypes of xml crashes at runtime
2 participants