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

Properly handle parsing of equals in chplconfig #26182

Merged
merged 5 commits into from
Oct 31, 2024

Conversation

jabraham17
Copy link
Member

@jabraham17 jabraham17 commented Oct 31, 2024

Properly handles the parsing of chplconfig files. #26178 added the ability to parse chplconfig variables with values including =, but that broke the warning for something like CHPL_VAR==value.

This PR resolves the issue by refactoring some of the parsing code in overrides.py to check error cases in skip_line, rather than relying on python exceptions. Then to avoid duplication of logic, renames skip_line to check_line and has it return the parsed variable.

Fixes the issue introduced in #26178 and reverts #26180

Tested by running start_test test/chplenv

[Reviewed by @DanilaFe]


parts = line.split('=', maxsplit=1)
var = parts[0].strip()
val = parts[-1].strip()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking about how you can silence the warning if there's a leading equal sign in a variable for real, and I'm coming up with nothing. I don't think you should strip the string for the purposes of warning about it. So:

A==B # warns
A == B # warns
A = =B # doesn't warn

Copy link
Member Author

Choose a reason for hiding this comment

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

This was an intentional choice that A = = B still warns. I think its more likely to be a mistake than truly what a user wants. If they want a value to start with =, writing A = '= B' should work

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as there's a way to silence the warning (A='=B' seems like it is one), I'm happy.

Copy link
Contributor

Choose a reason for hiding this comment

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

... Mind adding a test for A = '= B'?

Signed-off-by: Jade Abraham <[email protected]>
@jabraham17 jabraham17 merged commit ffff22f into chapel-lang:main Oct 31, 2024
7 checks passed
@jabraham17 jabraham17 deleted the fix-chplconfig-parse branch October 31, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants