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

Bugfix/zero number literal initialization #406

Merged
merged 3 commits into from
Jan 29, 2024

Conversation

lanarimarco
Copy link
Collaborator

Description

If the rpg code contains 0 formatted as 0000 or 00.00, the precision of such constants, computed through IntLiteral or RealLiteral, is always 1.

This behavior is due to the fact that:

  • for the integer constant: "0000".toLong() is 0 and the precision is 1
  • for the real constant: BigDecimal("00.00") has precision 1 and scale 2

While the first case was (more on less) predictable, the second one, honestly was not.

However, to fix this issue I have added property precision both for IntLiteral and RealLiteral and lightly changed the Expression.type() implementation.

This fix is necessary because Expression.type() is vital in the EDITC fixing which is in work in progress.

Checklist:

  • There are tests regarding this feature
  • The code follows the Kotlin conventions (run ./gradlew ktlintCheck)
  • The code passes all tests (run ./gradlew check)
  • There is a specific documentation in the docs directory

When expression is an instance of NumberLiteral and the literal is zero, the type returned from Expression.type is a NumberType with precision always zero
@lanarimarco
Copy link
Collaborator Author

@cosentino-smeup I have assigned you the code review because you are facing the editc issue, let me know if you need further support.

Copy link
Collaborator

@cosentino-smeup cosentino-smeup left a comment

Choose a reason for hiding this comment

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

Perfect. I am going to test it thoroughly when I will merge these changes in the branch "bugfix/NW23001440/EDITC_problems" because I'll have a wider number of user cases.

@cosentino-smeup cosentino-smeup merged commit 06b42f1 into develop Jan 29, 2024
1 check passed
@lanarimarco lanarimarco deleted the bugfix/zero_number_literal branch January 31, 2024 09:12
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