Skip to content

Fix JsValue::to_json with cyclic values - #4176

Merged
HalidOdat merged 4 commits into
boa-dev:mainfrom
changhc:fix-jsvalue-tojson
Mar 3, 2025
Merged

HalidOdat merged 4 commits into
boa-dev:mainfrom
changhc:fix-jsvalue-tojson

Conversation

@changhc

@changhc changhc commented Feb 24, 2025

Copy link
Copy Markdown
Contributor

This Pull Request fixes/closes #4175.

It changes the following:

  • The actual content of to_json is moved to a new internal method to_json_inner. This internal method takes one more argument stack that keeps track of objects seen so far. If the current object is in the stack, it means that there's a cycle and we return a TypeError.
  • to_json calls the internal method and returns results as usual.
  • A test case is added.

@changhc
changhc marked this pull request as ready for review February 24, 2025 21:56
@codecov

codecov Bot commented Feb 26, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.68%. Comparing base (6ddc2b4) to head (394cfdc).
Report is 388 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4176      +/-   ##
==========================================
+ Coverage   47.24%   52.68%   +5.44%     
==========================================
  Files         476      488      +12     
  Lines       46892    52005    +5113     
==========================================
+ Hits        22154    27401    +5247     
+ Misses      24738    24604     -134     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HalidOdat HalidOdat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me! Just a suggestion on improving this :)

@HalidOdat HalidOdat added the A-Bug Something isn't working label Mar 1, 2025
@HalidOdat
HalidOdat added this pull request to the merge queue Mar 3, 2025
Merged via the queue into boa-dev:main with commit c863b8c Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JsValue::to_json does not work with cyclic values

2 participants