Skip to content

x.json2: fix tests for deprecated function fast_raw_decode#24527

Merged
spytheman merged 2 commits into
vlang:masterfrom
lcheylus:tests-json2
May 20, 2025
Merged

x.json2: fix tests for deprecated function fast_raw_decode#24527
spytheman merged 2 commits into
vlang:masterfrom
lcheylus:tests-json2

Conversation

@lcheylus

@lcheylus lcheylus commented May 20, 2025

Copy link
Copy Markdown
Contributor

x.json2: fast_raw_decode deprecated after 2025-03-18 => needs to be replaced by decode[json.Any] instead

Fix tests in vlib/x/json2/tests/json2_test.v and vlib/x/json2/decoder2/tests/json2_tests/json2_test.v

Tests OK on Linux Debian/testing (amd64) with prod mode

  • Before this fix
$ ./v -prod test vlib/x/json2/tests/json2_test.v
---- Testing... ----------------------------------------------------------------------------------------------------------------------------
 FAIL     0.000 ms vlib/x/json2/tests/json2_test.v
>> compilation failed:
vlib/x/json2/tests/json2_test.v:19:12: error: function `x.json2.fast_raw_decode` has been deprecated since 2025-03-18, it will be an error after 2025-09-14; use `decode[json.Any]` instead
   17 | fn test_fast_raw_decode() {
   18 |     s := '{"name":"Peter","age":28,"salary":95000.5,"title":2}'
   19 |     o := json.fast_raw_decode(s) or {
      |               ~~~~~~~~~~~~~~~~~~
   20 |         assert false
   21 |         json.Any('')

--------------------------------------------------------------------------------------------------------------------------------------------
To reproduce just failure 1 run:    '/home/fox/dev/vlang.git/v' -prod '/home/fox/dev/vlang.git/vlib/x/json2/tests/json2_test.v'
Summary for all V _test.v files: 1 failed, 1 total. Elapsed time: 1067 ms, on 1 job. Comptime: 979 ms. Runtime: 0 ms.
  • After fix
$ ./v -prod test vlib/x/json2/tests/json2_test.v
---- Testing... ----------------------------------------------------------------------------------------------------------------------------
 OK       1.709 ms vlib/x/json2/tests/json2_test.v
--------------------------------------------------------------------------------------------------------------------------------------------
Summary for all V _test.v files: 1 passed, 1 total. Elapsed time: 7063 ms, on 1 job. Comptime: 7060 ms. Runtime: 1 ms.

Signed-off-by: Laurent Cheylus <foxy@free.fr>
@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22895

@enghitalo

Copy link
Copy Markdown
Contributor

I love you! Thank you!

@enghitalo

Copy link
Copy Markdown
Contributor

I think you can erase the fast_raw_decode function as well

@spytheman

spytheman commented May 20, 2025

Copy link
Copy Markdown
Contributor

The current deprecation policy, is to remove functions 6 months after the deprecation date (see doc/docs.md):

// You can also specify a date, after which the function will be
// considered deprecated. Before that date, calls to the function
// will be compiler notices - you will see them, but the compilation
// is not affected. After that date, calls will become warnings,
// so ordinary compiling will still work, but compiling with -prod
// will not (all warnings are treated like errors with -prod).
// 6 months after the deprecation date, calls will be hard
// compiler errors.

i.e. we can remove fast_raw_decode in September

@spytheman

spytheman commented May 20, 2025

Copy link
Copy Markdown
Contributor

btw, @lcheylus you can use v -W test . instead of v -prod test . (the later takes much longer) to find other instances of recent warnings, that have not been yet changed.
Thank you for doing this work 🙇🏻‍♂️ .

@spytheman spytheman merged commit 4dc3465 into vlang:master May 20, 2025
62 of 64 checks passed
@lcheylus lcheylus deleted the tests-json2 branch May 20, 2025 13:10
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.

4 participants