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 infinite recursion when calling to_text on an Atom with lazy field #12253

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

Akirathan
Copy link
Member

@Akirathan Akirathan commented Feb 10, 2025

Fixes #7138

Pull Request Description

Invoking to_text method on an atom with a lazy field may result in an infinite recursion. This PR fixes that by recognizing a lazy field, and printing it with just ~field_name, instead of evaluating it.

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.
  • If meaningful changes were made to logic or tests affecting Enso Cloud integration in the libraries,
    or the Snowflake database integration, a run of the Extra Tests has been scheduled.
    • If applicable, it is suggested to paste a link to a successful run of the Extra Tests.

@Akirathan Akirathan added CI: No changelog needed Do not require a changelog entry for this PR. CI: Clean build required CI runners will be cleaned before and after this PR is built. labels Feb 10, 2025
@Akirathan Akirathan self-assigned this Feb 10, 2025
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

  • fixes the problem - good
  • however this will prevent already computed fields to be visible
  • shouldn't we differentiate between computed/not yet computed lazy field?

@Akirathan
Copy link
Member Author

shouldn't we differentiate between computed/not yet computed lazy field?

Done in e6242ae by introducing a new message isFieldEvaluated on StructsLibrary.

@JaroslavTulach
Copy link
Member

shouldn't we differentiate between computed/not yet computed lazy field?

Done in e6242ae by introducing a new message isFieldEvaluated on StructsLibrary.

That's very clever idea!

  • all existing messages are untouched
  • default implementation of the isFieldEvaluated guarantees compatible behavior
  • only (the single) implementation of the library needs to be changed to report false

Very nice evolution approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Atoms with lazy fields cause StackOverflow in chrome inspector
6 participants