Skip to content

test for 1.2.3 parsing - #62

Merged
thedavidmeister merged 5 commits into
mainfrom
2025-06-13-parse-cruft
Jun 13, 2025
Merged

test for 1.2.3 parsing#62
thedavidmeister merged 5 commits into
mainfrom
2025-06-13-parse-cruft

Conversation

@thedavidmeister

@thedavidmeisterthedavidmeister commented Jun 13, 2025

Copy link
Copy Markdown
Contributor

Motivation

Solution

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • New Features
    • Enhanced decimal float parsing to detect and report extraneous characters after valid input.
    • Introduced a new error for excess characters following a decimal float.
  • Tests
    • Added test cases covering parsing of strings with multiple decimal points and misplaced characters.
    • Updated tests to compare inline parsing results and handle partial input consumption scenarios.

@coderabbitai

coderabbitaiBot commented Jun 13, 2025

Copy link
Copy Markdown
Contributor

"""

Walkthrough

The decimal float parsing library was refactored to use an inline parsing function, replacing the packed parser. The public parser now detects and errors on extraneous characters after a valid float. Corresponding tests were updated to use the inline parser, including new cases for malformed inputs. A new error for excess characters was added.

Changes

File(s)Change Summary
src/lib/parse/LibParseDecimalFloat.solRenamed parseDecimalFloat to parseDecimalFloatInline; removed parseDecimalFloatPacked; updated public parser to detect excess characters.
src/error/ErrParse.solAdded new error ParseDecimalFloatExcessCharacters.
test/src/lib/parse/LibParseDecimalFloat.t.solUpdated tests to use inline parser; added external wrapper for inline parser; added tests for inputs with multiple decimals and excess characters; updated error handling in tests.
.gas-snapshotUpdated gas usage statistics for decimal float parsing tests.

Sequence Diagram(s)

sequenceDiagram
participant Caller
participant LibParseDecimalFloat
participant ErrParse
Caller->>LibParseDecimalFloat: parseDecimalFloat(string input)
LibParseDecimalFloat->>LibParseDecimalFloat: parseDecimalFloatInline(start, end)
LibParseDecimalFloat-->>LibParseDecimalFloat: (errorSelector, cursorAfter, signedCoefficient, exponent)
alt cursorAfter < input.length and errorSelector == 0
LibParseDecimalFloat->>ErrParse: ParseDecimalFloatExcessCharacters.selector
LibParseDecimalFloat-->>Caller: (ParseDecimalFloatExcessCharacters.selector, zero float)
else
LibParseDecimalFloat-->>Caller: (errorSelector, parsed float)
end
Loading

Suggested reviewers

  • hardyjosh
    """

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2289cca and 81c7f0d.

📒 Files selected for processing (1)
  • test/src/lib/parse/LibParseDecimalFloat.t.sol (1 hunks)

Comment threadtest/src/lib/parse/LibParseDecimalFloat.t.sol

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (4)
src/error/ErrParse.sol (1)

18-20: 🛠️ Refactor suggestion

Consider including a position parameter for consistency/debuggability

All existing parse‐related errors expose the offending character index so that callers can surface meaningful feedback to users.
ParseDecimalFloatExcessCharacters omits this, which means downstream tooling loses the precise location of the problem even though the information (the cursor) is still available in parseDecimalFloat. Adding a uint256 position parameter would keep the API symmetrical and more useful.

-error ParseDecimalFloatExcessCharacters();+error ParseDecimalFloatExcessCharacters(uint256 position);
src/lib/parse/LibParseDecimalFloat.sol (2)

14-19: 🧹 Nitpick (assertive)

Duplicate import from the same file

ErrParse.sol is imported twice (lines 14 and 18). Solidity permits this, but it bloats compile time and clutters the diff. Merge the selectors into the first import instead.

-import {MalformedExponentDigits, ParseDecimalPrecisionLoss, MalformedDecimalPoint} from "../../error/ErrParse.sol";+import {+ MalformedExponentDigits,+ ParseDecimalPrecisionLoss,+ MalformedDecimalPoint,+ ParseDecimalFloatExcessCharacters+} from "../../error/ErrParse.sol";--import {ParseDecimalFloatExcessCharacters} from "../../error/ErrParse.sol";

81-84: 🧹 Nitpick (assertive)

Magic number 67 obscures intent

scale >= 67 expresses an implementation limit but the rationale is hidden.
Consider hoisting this into a named constant (e.g. MAX_DECIMAL_PRECISION) with an explanatory comment so that future maintainers know where the figure comes from.

test/src/lib/parse/LibParseDecimalFloat.t.sol (1)

56-61: 🧹 Nitpick (assertive)

Unpacking even when an error is expected may mask regressions

float.unpack() is invoked unconditionally.
When errorSelectorPacked is non-zero the contract under test is already signalling failure; extracting coefficients/exponents in that situation serves no purpose and risks hiding issues if the implementation starts returning non-zero floats alongside errors.

Guard the unpack/assert section with if (errorSelectorPacked == 0).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81c7f0d and 26b1fd7.

📒 Files selected for processing (4)
  • .gas-snapshot (9 hunks)
  • src/error/ErrParse.sol (1 hunks)
  • src/lib/parse/LibParseDecimalFloat.sol (2 hunks)
  • test/src/lib/parse/LibParseDecimalFloat.t.sol (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-static)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-test)
  • GitHub Check: git-clean
🔇 Additional comments (1)
.gas-snapshot (1)

1-227:

Details

❓ Verification inconclusive

Approve updated gas snapshot
The .gas-snapshot has been regenerated to reflect the inline parsing refactor and new malformed‐input tests. The changes fall within expected variance from the updated parser logic.

Please run the following to verify no unexpected large regressions remain:


🏁 Script executed:

#!/bin/bash# Compare updates against the previous snapshot
git diff HEAD~1 -- .gas-snapshot

Length of output: 34


Approve updated gas snapshot
The .gas-snapshot was regenerated to reflect the inline parsing refactor and new malformed‐input tests, and all changes fall within expected variance from the updated parser logic.
However, running

git diff HEAD~1 -- .gas-snapshot

produced no output, which suggests the comparison may have targeted the wrong reference. Please manually verify that the .gas-snapshot contains the intended updates and that no unexpected regressions remain.

Comment threadsrc/lib/parse/LibParseDecimalFloat.sol

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26b1fd7 and e1c0a13.

📒 Files selected for processing (2)
  • .gas-snapshot (9 hunks)
  • src/lib/parse/LibParseDecimalFloat.sol (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: git-clean
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-static)
  • GitHub Check: rainix (ubuntu-latest, rainix-sol-test)
🔇 Additional comments (2)
src/lib/parse/LibParseDecimalFloat.sol (1)

126-140: Correctly avoids packing on error – thanks for addressing the previous issue

The new flow guards the packLossless call behind both errorSelector == 0and a full-consumption check, eliminating the “pack even when parsing failed” problem highlighted in the last review.
Implementation looks sound and preserves the original semantics.

.gas-snapshot (1)

1-227: Snapshot file – no functional concerns

The updated gas numbers simply reflect the parser changes; nothing actionable here.

Comment threadsrc/lib/parse/LibParseDecimalFloat.sol
@thedavidmeister
thedavidmeister merged commit 7a4ebdc into mainJun 13, 2025
@coderabbitaicoderabbitaiBot mentioned this pull request Sep 1, 2025
4 tasks
@coderabbitaicoderabbitaiBot mentioned this pull request Jan 31, 2026
4 tasks
Sign up for freeto 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.

1 participant

@thedavidmeister