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: double map #4169

Merged
merged 2 commits into from
Oct 15, 2024
Merged

Bugfix: double map #4169

merged 2 commits into from
Oct 15, 2024

Conversation

adamchalmers
Copy link
Collaborator

@adamchalmers adamchalmers commented Oct 15, 2024

Previously running map would change the output of the array, it would go from array of numbers to an array of objects that contain numbers. Fixed now.

We should do #1130 to make this impossible in the future.

Copy link

qa-wolf bot commented Oct 15, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link

vercel bot commented Oct 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Oct 15, 2024 10:39pm

@adamchalmers adamchalmers changed the title Reproduce the double-map bug Bugfix: double map Oct 15, 2024
@adamchalmers adamchalmers requested a review from jtran October 15, 2024 22:10
To repro, run:

```
cargo nextest run --test executor -E "test(no_visuals::double_map)"
```

The program emits this error:

Syntax(KclErrorDetails {
 source_ranges: [SourceRange([31, 32])],
 message: "Invalid number: {\"type\":\"UserVal\",\"value\":1.0,\"__meta\":[{\"sourceRange\":[31,36]}]}"
})

In other words, the second `map` statement is being passed an array of JSON STRINGS, not an array of numbers.
The strings contain JSON stringified representations of user values which are numbers.
@adamchalmers adamchalmers force-pushed the achalmers/double-map-bug branch from f7640e0 to a9dc448 Compare October 15, 2024 22:11
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 86.21%. Comparing base (0811d9f) to head (a9dc448).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/wasm-lib/kcl/src/std/array.rs 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4169      +/-   ##
==========================================
- Coverage   86.22%   86.21%   -0.01%     
==========================================
  Files          75       75              
  Lines       26689    26701      +12     
==========================================
+ Hits        23013    23021       +8     
- Misses       3676     3680       +4     
Flag Coverage Δ
wasm-lib 86.21% <83.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@adamchalmers adamchalmers merged commit fbac993 into main Oct 15, 2024
29 of 32 checks passed
@adamchalmers adamchalmers deleted the achalmers/double-map-bug branch October 15, 2024 22:58
lf94 pushed a commit that referenced this pull request Oct 16, 2024
Previously, map was wrapping KCL values in a JSON object unnecessarily.  The new `double_map` test would emit this error:

```
Syntax(KclErrorDetails {
 source_ranges: [SourceRange([31, 32])],
 message: "Invalid number: {\"type\":\"UserVal\",\"value\":1.0,\"__meta\":[{\"sourceRange\":[31,36]}]}"
})
```

In other words, the second `map` statement is being passed an array of JSON STRINGS, not an array of numbers.
The strings contain JSON stringified representations of user values which are numbers.

Bug is now fixed.
@pierremtb pierremtb mentioned this pull request Oct 17, 2024
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