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

better error and dca for configurables #6121

Merged
merged 12 commits into from
Jul 5, 2024

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Jun 13, 2024

Description

This PR closes #6118.

If for some reason an older core ends up being used, we now warn with a more user-friendly error.

error: Configurables need a function named "abi_decode_in_place" to be in scope.
  --> /home/xunilrj/github/sway/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/src/main.sw:42:5
   |
...
42 |     ARRAY_BOOL: [bool; 3] = [true, false, true],
   |     ^^^^^^^^^^
   |
   = help: Certify you are accessing a compatible version of the "core" library.
____

We also use a better span when warning about unused configurables.

warning
  --> /home/xunilrj/github/sway/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/src/main.sw:47:5
   |
45 | 
46 | 
47 |     NOT_USED: u8 = 1,
   |     -------- This declaration is never used.
48 |     #[allow(dead_code)]
49 |     NOT_USED_BUT_ALLOWED: u8 = 2,
   |
____

  Compiled script "configurable_consts" with 1 warning.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@xunilrj xunilrj requested review from a team as code owners June 13, 2024 15:34
Copy link

Benchmark for a3a48db

Click to view benchmark
Test Base PR %
code_action 5.1±0.10ms 5.1±0.23ms 0.00%
code_lens 338.1±7.72ns 292.7±10.09ns -13.43%
compile 3.6±0.06s 3.5±0.07s -2.78%
completion 4.7±0.02ms 4.7±0.13ms 0.00%
did_change_with_caching 3.3±0.08s 3.3±0.11s 0.00%
document_symbol 932.2±16.64µs 956.6±18.71µs +2.62%
format 90.0±1.65ms 89.2±0.78ms -0.89%
goto_definition 348.7±8.16µs 361.8±12.85µs +3.76%
highlight 8.7±0.33ms 8.8±0.03ms +1.15%
hover 570.4±8.77µs 588.4±4.30µs +3.16%
idents_at_position 120.2±0.69µs 124.4±2.88µs +3.49%
inlay_hints 646.1±48.02µs 641.0±22.75µs -0.79%
on_enter 464.2±19.14ns 462.9±14.71ns -0.28%
parent_decl_at_position 3.6±0.03ms 3.6±0.05ms 0.00%
prepare_rename 349.1±5.64µs 358.4±5.45µs +2.66%
rename 8.9±0.15ms 9.2±0.55ms +3.37%
semantic_tokens 939.6±16.96µs 944.2±15.63µs +0.49%
token_at_position 355.5±3.58µs 351.2±2.70µs -1.21%
tokens_at_position 3.6±0.19ms 3.6±0.05ms 0.00%
tokens_for_file 415.5±17.63µs 412.1±5.55µs -0.82%
traverse 37.3±0.79ms 37.0±0.76ms -0.80%

Copy link

Benchmark for 6b6ef74

Click to view benchmark
Test Base PR %
code_action 5.1±0.03ms 5.1±0.07ms 0.00%
code_lens 341.1±6.47ns 283.3±7.88ns -16.95%
compile 3.4±0.10s 3.7±0.13s +8.82%
completion 4.7±0.02ms 4.7±0.21ms 0.00%
did_change_with_caching 3.2±0.07s 3.2±0.09s 0.00%
document_symbol 946.1±66.39µs 990.7±28.23µs +4.71%
format 88.2±1.84ms 90.4±1.22ms +2.49%
goto_definition 359.1±12.56µs 359.0±8.90µs -0.03%
highlight 8.7±0.27ms 8.9±0.25ms +2.30%
hover 592.5±7.67µs 581.3±11.36µs -1.89%
idents_at_position 121.0±0.38µs 121.2±1.93µs +0.17%
inlay_hints 648.3±22.53µs 652.5±28.60µs +0.65%
on_enter 466.6±29.86ns 463.3±9.51ns -0.71%
parent_decl_at_position 3.7±0.80ms 3.7±0.13ms 0.00%
prepare_rename 352.8±9.07µs 358.8±7.78µs +1.70%
rename 8.9±0.05ms 9.1±0.17ms +2.25%
semantic_tokens 978.6±19.08µs 966.1±11.66µs -1.28%
token_at_position 394.3±19.04µs 347.6±3.54µs -11.84%
tokens_at_position 3.6±0.04ms 3.6±0.09ms 0.00%
tokens_for_file 431.9±1.93µs 418.7±6.35µs -3.06%
traverse 37.4±1.34ms 46.1±2.23ms +23.26%

sway-error/src/error.rs Outdated Show resolved Hide resolved
sway-error/src/handler.rs Outdated Show resolved Hide resolved
sway-error/src/error.rs Outdated Show resolved Hide resolved
sway-error/src/error.rs Outdated Show resolved Hide resolved
@xunilrj xunilrj requested a review from ironcev June 14, 2024 09:01
Copy link

Benchmark for 24f90f9

Click to view benchmark
Test Base PR %
code_action 5.3±0.17ms 5.0±0.02ms -5.66%
code_lens 337.8±12.54ns 287.6±7.27ns -14.86%
compile 3.4±0.06s 3.4±0.07s 0.00%
completion 4.8±0.10ms 4.7±0.02ms -2.08%
did_change_with_caching 3.3±0.09s 3.2±0.07s -3.03%
document_symbol 951.0±23.97µs 959.2±22.89µs +0.86%
format 89.0±1.55ms 89.1±1.23ms +0.11%
goto_definition 356.7±6.29µs 350.7±6.54µs -1.68%
highlight 9.1±0.51ms 8.7±0.19ms -4.40%
hover 581.3±5.45µs 575.4±5.70µs -1.01%
idents_at_position 121.5±1.01µs 119.8±0.42µs -1.40%
inlay_hints 657.9±4.35µs 681.7±24.80µs +3.62%
on_enter 462.8±4.88ns 465.5±10.89ns +0.58%
parent_decl_at_position 3.7±0.03ms 3.6±0.09ms -2.70%
prepare_rename 356.5±6.04µs 350.1±5.35µs -1.80%
rename 9.3±0.10ms 8.9±0.56ms -4.30%
semantic_tokens 954.0±13.90µs 965.5±15.32µs +1.21%
token_at_position 351.0±1.68µs 347.8±3.25µs -0.91%
tokens_at_position 3.8±0.15ms 3.6±0.04ms -5.26%
tokens_for_file 409.4±3.74µs 411.7±2.40µs +0.56%
traverse 35.8±0.39ms 35.7±0.53ms -0.28%

sway-error/src/error.rs Outdated Show resolved Hide resolved
@xunilrj
Copy link
Contributor Author

xunilrj commented Jun 25, 2024

As discussed, the error now points to the configurable block:

image

@xunilrj xunilrj force-pushed the xunilrj/configurables-better-error-and-dca branch from 58152c6 to 0a6fdb2 Compare June 25, 2024 14:54
Copy link

Benchmark for 56c2e27

Click to view benchmark
Test Base PR %
code_action 5.1±0.10ms 5.0±0.03ms -1.96%
code_lens 309.6±24.56ns 278.1±7.42ns -10.17%
compile 3.4±0.08s 3.4±0.08s 0.00%
completion 4.6±0.13ms 4.6±0.11ms 0.00%
did_change_with_caching 3.2±0.08s 3.2±0.08s 0.00%
document_symbol 919.4±17.15µs 868.4±8.19µs -5.55%
format 87.9±2.42ms 87.2±1.00ms -0.80%
goto_definition 339.3±5.90µs 347.9±8.14µs +2.53%
highlight 8.7±0.21ms 8.7±0.19ms 0.00%
hover 568.5±6.04µs 565.6±5.94µs -0.51%
idents_at_position 118.4±0.50µs 120.8±1.35µs +2.03%
inlay_hints 627.2±7.42µs 621.3±25.61µs -0.94%
on_enter 467.5±9.34ns 460.1±11.74ns -1.58%
parent_decl_at_position 3.5±0.03ms 3.6±0.04ms +2.86%
prepare_rename 339.8±7.13µs 341.2±5.94µs +0.41%
rename 8.9±0.16ms 9.0±0.27ms +1.12%
semantic_tokens 1257.3±14.25µs 1261.3±12.47µs +0.32%
token_at_position 336.2±3.69µs 335.5±2.08µs -0.21%
tokens_at_position 3.5±0.03ms 3.6±0.05ms +2.86%
tokens_for_file 393.7±2.86µs 404.7±2.35µs +2.79%
traverse 36.6±0.44ms 37.0±0.59ms +1.09%

ironcev
ironcev previously approved these changes Jun 25, 2024
Copy link

Benchmark for 408d703

Click to view benchmark
Test Base PR %
code_action 5.0±0.03ms 5.0±0.11ms 0.00%
code_lens 304.1±10.12ns 284.0±20.08ns -6.61%
compile 3.4±0.05s 3.5±0.10s +2.94%
completion 4.6±0.07ms 4.6±0.02ms 0.00%
did_change_with_caching 3.2±0.09s 3.2±0.07s 0.00%
document_symbol 904.8±33.87µs 873.6±31.45µs -3.45%
format 86.9±0.75ms 88.4±1.60ms +1.73%
goto_definition 341.7±8.67µs 342.2±10.05µs +0.15%
highlight 8.6±0.04ms 8.7±0.03ms +1.16%
hover 569.6±14.43µs 568.7±6.80µs -0.16%
idents_at_position 119.7±0.45µs 123.2±0.33µs +2.92%
inlay_hints 632.4±31.41µs 637.2±27.73µs +0.76%
on_enter 472.3±14.51ns 463.7±36.72ns -1.82%
parent_decl_at_position 3.6±0.01ms 3.6±0.04ms 0.00%
prepare_rename 343.6±7.54µs 343.1±6.72µs -0.15%
rename 8.9±0.03ms 8.9±0.02ms 0.00%
semantic_tokens 1228.4±17.33µs 1285.8±7.82µs +4.67%
token_at_position 342.6±3.20µs 341.3±3.42µs -0.38%
tokens_at_position 3.6±0.04ms 3.5±0.04ms -2.78%
tokens_for_file 398.4±3.17µs 399.3±2.03µs +0.23%
traverse 37.4±0.78ms 37.7±0.69ms +0.80%

@xunilrj xunilrj requested review from sdankel and ironcev June 25, 2024 20:46
ironcev
ironcev previously approved these changes Jun 25, 2024
@xunilrj xunilrj force-pushed the xunilrj/configurables-better-error-and-dca branch from 843ffa5 to 9eb36e3 Compare June 27, 2024 13:09
Copy link

Benchmark for 963be78

Click to view benchmark
Test Base PR %
code_action 5.2±0.05ms 5.0±0.10ms -3.85%
code_lens 285.3±19.12ns 286.8±9.51ns +0.53%
compile 2.6±0.03s 2.5±0.03s -3.85%
completion 4.7±0.17ms 4.6±0.19ms -2.13%
did_change_with_caching 2.5±0.03s 2.5±0.03s 0.00%
document_symbol 845.3±19.91µs 884.2±65.13µs +4.60%
format 82.0±0.80ms 82.4±0.79ms +0.49%
goto_definition 335.6±7.49µs 339.0±7.11µs +1.01%
highlight 9.1±0.14ms 8.6±0.02ms -5.49%
hover 485.9±6.67µs 485.9±7.63µs 0.00%
idents_at_position 121.0±0.31µs 121.9±2.05µs +0.74%
inlay_hints 642.8±22.79µs 684.4±8.10µs +6.47%
on_enter 464.8±13.96ns 468.6±22.58ns +0.82%
parent_decl_at_position 3.7±0.06ms 3.5±0.04ms -5.41%
prepare_rename 334.5±7.60µs 340.3±11.34µs +1.73%
rename 9.3±0.05ms 8.9±0.17ms -4.30%
semantic_tokens 1207.7±9.97µs 1268.6±31.19µs +5.04%
token_at_position 327.2±1.88µs 332.8±2.56µs +1.71%
tokens_at_position 3.7±0.03ms 3.5±0.02ms -5.41%
tokens_for_file 400.9±1.85µs 401.2±2.86µs +0.07%
traverse 37.8±0.77ms 38.5±0.82ms +1.85%

@IGI-111 IGI-111 requested review from ironcev and a team June 27, 2024 14:06
Copy link

Benchmark for 0ded602

Click to view benchmark
Test Base PR %
code_action 5.3±0.18ms 5.2±0.11ms -1.89%
code_lens 281.3±14.57ns 280.9±18.52ns -0.14%
compile 2.7±0.04s 2.6±0.05s -3.70%
completion 4.8±0.12ms 4.8±0.11ms 0.00%
did_change_with_caching 2.6±0.03s 2.5±0.04s -3.85%
document_symbol 916.4±44.13µs 932.5±22.44µs +1.76%
format 74.5±2.25ms 74.6±1.58ms +0.13%
goto_definition 335.5±6.54µs 341.5±7.85µs +1.79%
highlight 9.0±0.15ms 9.1±0.15ms +1.11%
hover 489.3±4.18µs 493.1±5.88µs +0.78%
idents_at_position 120.1±2.47µs 118.4±1.66µs -1.42%
inlay_hints 650.5±28.60µs 649.9±32.24µs -0.09%
on_enter 473.5±13.90ns 481.4±35.79ns +1.67%
parent_decl_at_position 3.7±0.12ms 3.7±0.15ms 0.00%
prepare_rename 335.5±7.48µs 344.4±20.62µs +2.65%
rename 9.5±0.14ms 9.4±0.19ms -1.05%
semantic_tokens 1265.4±49.19µs 1275.9±16.28µs +0.83%
token_at_position 336.3±3.76µs 334.6±2.99µs -0.51%
tokens_at_position 3.8±0.08ms 3.7±0.07ms -2.63%
tokens_for_file 408.1±7.44µs 399.2±3.19µs -2.18%
traverse 39.0±0.61ms 38.3±0.75ms -1.79%

@xunilrj xunilrj force-pushed the xunilrj/configurables-better-error-and-dca branch from 445ae17 to 53fbf89 Compare July 4, 2024 10:47
Copy link

github-actions bot commented Jul 4, 2024

Benchmark for 911fbe1

Click to view benchmark
Test Base PR %
code_action 5.2±0.06ms 5.2±0.11ms 0.00%
code_lens 282.2±9.00ns 282.9±10.59ns +0.25%
compile 2.6±0.04s 2.5±0.03s -3.85%
completion 4.7±0.06ms 4.7±0.07ms 0.00%
did_change_with_caching 2.5±0.03s 2.5±0.02s 0.00%
document_symbol 908.0±48.37µs 885.7±43.01µs -2.46%
format 71.4±0.82ms 73.1±1.67ms +2.38%
goto_definition 338.7±7.42µs 342.8±4.24µs +1.21%
highlight 9.1±0.03ms 9.0±0.18ms -1.10%
hover 491.0±5.62µs 498.8±7.47µs +1.59%
idents_at_position 119.7±0.32µs 117.8±0.60µs -1.59%
inlay_hints 634.3±36.85µs 642.7±26.27µs +1.32%
on_enter 458.9±11.88ns 478.4±28.78ns +4.25%
parent_decl_at_position 3.7±0.02ms 3.7±0.04ms 0.00%
prepare_rename 330.1±7.61µs 341.1±7.27µs +3.33%
rename 9.3±0.13ms 9.2±0.03ms -1.08%
semantic_tokens 1255.5±8.74µs 1277.2±12.73µs +1.73%
token_at_position 335.1±2.49µs 339.3±2.25µs +1.25%
tokens_at_position 3.7±0.04ms 3.7±0.03ms 0.00%
tokens_for_file 396.9±2.69µs 402.5±3.06µs +1.41%
traverse 36.0±1.15ms 37.9±0.74ms +5.28%

@IGI-111 IGI-111 requested a review from a team July 4, 2024 13:51
@JoshuaBatty JoshuaBatty enabled auto-merge (squash) July 5, 2024 00:10
@JoshuaBatty JoshuaBatty merged commit 00a9254 into master Jul 5, 2024
38 checks passed
@JoshuaBatty JoshuaBatty deleted the xunilrj/configurables-better-error-and-dca branch July 5, 2024 00:22
Copy link

github-actions bot commented Jul 5, 2024

Benchmark for 2115c8c

Click to view benchmark
Test Base PR %
code_action 5.2±0.09ms 5.3±0.09ms +1.92%
code_lens 284.1±14.66ns 283.5±6.02ns -0.21%
compile 2.5±0.03s 2.5±0.03s 0.00%
completion 4.7±0.01ms 4.6±0.02ms -2.13%
did_change_with_caching 2.4±0.02s 2.5±0.02s +4.17%
document_symbol 859.5±25.27µs 895.4±25.09µs +4.18%
format 71.3±0.91ms 71.0±0.80ms -0.42%
goto_definition 337.6±3.87µs 335.2±4.34µs -0.71%
highlight 9.0±0.09ms 9.0±0.09ms 0.00%
hover 491.2±6.86µs 491.1±5.74µs -0.02%
idents_at_position 119.5±1.00µs 118.3±1.58µs -1.00%
inlay_hints 641.6±28.46µs 638.6±23.38µs -0.47%
on_enter 464.8±6.01ns 498.3±18.48ns +7.21%
parent_decl_at_position 3.7±0.02ms 3.7±0.04ms 0.00%
prepare_rename 337.1±5.38µs 355.9±6.60µs +5.58%
rename 9.3±0.15ms 9.3±0.09ms 0.00%
semantic_tokens 1186.8±9.72µs 1198.2±14.16µs +0.96%
token_at_position 344.1±32.22µs 335.7±4.99µs -2.44%
tokens_at_position 3.7±0.01ms 3.7±0.04ms 0.00%
tokens_for_file 425.5±2.87µs 395.4±1.86µs -7.07%
traverse 36.2±1.09ms 36.1±0.55ms -0.28%

@xunilrj xunilrj mentioned this pull request Jul 8, 2024
28 tasks
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.

Compiler panics and no DCA warning when a configurable is never used
5 participants