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

KCL: No 'let' or 'const' required when declaring vars #4063

Merged
merged 32 commits into from
Oct 2, 2024

Conversation

adamchalmers
Copy link
Collaborator

@adamchalmers adamchalmers commented Oct 1, 2024

Previously variable declaration required a keyword, e.g.

let x = 4
const x = 4
var x = 4

These were all valid, and did the exact same thing. As of this PR, they're all still valid, but the KCL formatter will change them all to just:

x = 4

which is the new preferred way to declare a constant.

Screenshots demonstrate that let, const, var and naked declarations all work:

Screenshot 2024-10-01 at 1 16 41 PM

But the formatter will remove the var/let/const keywords.

Closes #3985

Copy link

qa-wolf bot commented Oct 1, 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!

@adamchalmers adamchalmers requested a review from jtran October 1, 2024 16:23
Copy link

vercel bot commented Oct 1, 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 2, 2024 6:38pm

@jessfraz
Copy link
Contributor

jessfraz commented Oct 1, 2024

can you update the types doc its a manual doc of stuff like this in docs/kcl/types

@adamchalmers
Copy link
Collaborator Author

can you update the types doc its a manual doc of stuff like this in docs/kcl/types

Done!

@adamchalmers adamchalmers force-pushed the achalmers/no-let-necessary branch 2 times, most recently from 64b2320 to 2250297 Compare October 1, 2024 18:28
Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.21%. Comparing base (88cd274) to head (e0afd4f).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4063      +/-   ##
==========================================
+ Coverage   86.16%   86.21%   +0.04%     
==========================================
  Files          75       75              
  Lines       26423    26454      +31     
==========================================
+ Hits        22768    22806      +38     
+ Misses       3655     3648       -7     
Flag Coverage Δ
wasm-lib 86.21% <ø> (+0.04%) ⬆️

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.

The test was failing because 'myVar' could be found in two places, and
it was told to just "click on 'myVar'". That wasn't ambiguous before when
the code editor had `const myVar =` but now with the naked assignment, it is.

Solution is to make it more specific and find 'myVar' in the code editor.
@adamchalmers adamchalmers force-pushed the achalmers/no-let-necessary branch 2 times, most recently from fd28685 to 6102a7f Compare October 2, 2024 16:17
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.

Remove declaration keywords
3 participants