Compare commits

...

1109 Commits

Author SHA1 Message Date
Jef Roosens e9aca12560
ci: switched to vieter-v
ci/woodpecker/push/vc Pipeline was successful Details
ci/woodpecker/push/docker Pipeline was successful Details
ci/woodpecker/push/arch Pipeline was successful Details
2022-06-24 08:47:37 +02:00
Jef Roosens ad966c29c2
ci: disable gc by default 2022-06-24 08:47:37 +02:00
Jef Roosens 0e3efb655e
ci: Added docker workflow & Dockerfile 2022-06-24 08:47:37 +02:00
Jef Roosens b817f8ebc9
ci: bumped alpine version & added mandoc to builder image 2022-06-24 08:47:36 +02:00
Jef Roosens 3d0ecd0a2d
ci: Added PKGBUILD & workflow for deploying Arch packages 2022-06-24 08:47:36 +02:00
Jef Roosens 77b5845c2c
ci: Added docker workflow & Dockerfile 2022-06-24 08:47:34 +02:00
CC d336b7b877
examples: add another vweb example, showing file upload, transform, and file download (#14842) 2022-06-24 09:23:47 +03:00
Delyan Angelov ccc3271493 docs: restore the important sentence about the mutable args that have to be marked on call 2022-06-23 21:15:21 +03:00
Emirhan Yener e5bbb23389
examples: fix 2048 gameplay (#14838) 2022-06-23 21:07:30 +03:00
Wertzui123 c10ba6d81a
os: add `.cmd` to the list of Windows executable suffixes (#14839) 2022-06-23 20:12:29 +03:00
Delyan Angelov b0fe21f018
ci: fix long lines/links in docs.md 2022-06-23 20:09:20 +03:00
Alexander Medvednikov c17200c33d
doc: clear up concurrency and immutable fn args 2022-06-23 17:46:57 +03:00
Larpon 298dc77c38
ci: add pure `-os android` checks (#14837) 2022-06-23 11:22:55 +03:00
yuyi e9a8f5fcc7
cgen: fix ref_struct.str() with null pointer (#14836) 2022-06-23 08:35:21 +03:00
Wertzui123 587101a1ea
os: fix `find_abs_path_of_executable` function (on Windows) (#14835) 2022-06-23 03:36:15 +03:00
Delyan Angelov 2524207d1c
tools: support c2v.exe in `v translate`, use os.quoted_path, cleanup errors. 2022-06-23 03:31:10 +03:00
Alexander Medvednikov 78c527b243
tutorials: improve c2v tutorial a bit 2022-06-23 02:45:14 +03:00
Alexander Medvednikov dbc51a4579
readme: add c2v demo 2022-06-23 02:33:09 +03:00
l-m ed8c63cc0b
builtin: add a contains_only method on string (#14830) 2022-06-23 01:41:42 +03:00
Delyan Angelov a7108ff05c
docs: use the actual most recent output of c2v in the example 2022-06-23 01:39:39 +03:00
Delyan Angelov b8d9bfec16
docs: fix C primes example in the tutorials (fixes c2v translation on linux) 2022-06-23 01:35:45 +03:00
Delyan Angelov 436081a9f5
ci: fix `v check-md tutorials/` 2022-06-23 01:30:22 +03:00
Delyan Angelov 1b87a4770c
tutorials: rename the folder containing spaces, to fix git checkouts on windows 2022-06-23 01:08:07 +03:00
Delyan Angelov 856270cac2
tutorials: restore the old tutorials/building_a_simple_web_blog_with_vweb/ folder. 2022-06-23 00:11:59 +03:00
Alexander Medvednikov 989c5e26f5 c2v: use https git clone 2022-06-22 22:49:29 +03:00
Alexander Medvednikov fe673e7963 tutorials: rename vweb tutorial 2022-06-22 22:48:40 +03:00
Alexander Medvednikov ae2183043b tutorials: c2v 2022-06-22 22:47:43 +03:00
Dialga 5cd5d551e3
v.pkgconfig: fix building standalone pkgconfig (#14825)
* Update main.v

* add test to prevent future regressions

Co-authored-by: Delyan Angelov <delian66@gmail.com>
2022-06-22 22:38:50 +03:00
Alexander Medvednikov c9ab086029 cmd/tools: enable c2v 2022-06-22 22:10:46 +03:00
yuyi e6c3de2f46
cgen: format cgen.init() generated c codes (#14824) 2022-06-22 21:39:15 +03:00
Larpon 3fb88500a2
os: improve Android interop (#14827) 2022-06-22 21:38:27 +03:00
yuyi 585b5145fa
cgen: fix auto string method generated for []&int{len:1} (#14829) 2022-06-22 14:54:04 +03:00
Delyan Angelov 6a4ba22eae
tests: flush test headers to ensure stable output with VJOBS>1 2022-06-22 12:46:32 +03:00
pancake 23d1c792c0
native: fix macho generation for macos11-amd64 (#14821) 2022-06-22 11:58:27 +03:00
Delyan Angelov 74fb473301
ci: use unique concurrency.group for native_backend_tests.yml 2022-06-22 11:23:40 +03:00
Delyan Angelov 6c060b76fd
ci: fix v building inside native_backend_tests.yml 2022-06-22 11:19:00 +03:00
Delyan Angelov 48b2ab157b
ci: add a separate native_backend_tests.yml, to run the native tests on all the available github actions vm environments 2022-06-22 09:11:01 +03:00
yuyi c64c4907a2
parser: check closure var name conflict (#14823) 2022-06-22 09:04:15 +03:00
Delyan Angelov e2e3992e0d
ci: remove `continue-on-error: true` for most ci jobs (#14811) 2022-06-22 00:20:57 +03:00
ghosttk 8172fecb51
vweb: remove the extra '/' in scan_static_directory (#14806) 2022-06-21 15:13:09 +03:00
Larpon 9f5e442dab
tools: add bump flags to vcomplete (#14813) 2022-06-21 15:11:42 +03:00
yuyi c160ba2a8d
checker: stricter mutable reference check (fix #14803) (#14805) 2022-06-21 13:23:21 +03:00
Delyan Angelov c6f94e9cab
tools: distribute vpm queries randomly between the available backend servers 2022-06-21 12:58:37 +03:00
yuyi cab6355a38
cgen: fix array of reference sumtype index() (#14812) 2022-06-21 12:37:54 +03:00
Delyan Angelov f08c768c8e
tools: add a new readonly VPM server mirror url, to mitigate failures of the main vpm.vlang.io 2022-06-21 12:27:41 +03:00
Ulises Jeremias Cornejo Fandos e505fcdac0
encoding.csv: update reader.v (#14807) 2022-06-21 08:31:47 +03:00
yuyi f6f77e5264
clipboard: make clipboard.Clipboard public on windows (#14810) 2022-06-21 08:21:54 +03:00
David 'Epper' Marshall 524df8da1b
math: add zpl stuff (#14543) 2022-06-21 00:17:49 +03:00
Delyan Angelov 473d26ce47 builtin: enforce linking to libgc.a with -prod on macos 2022-06-20 21:29:27 +03:00
pancake 1caff5b379
native: initial support for apple-m1 (#14795) 2022-06-20 21:25:12 +03:00
yuyi 8703e336e0
checker: cleanup in fn_decl() (#14802) 2022-06-20 17:56:02 +03:00
Delyan Angelov 1fc9e1a716
tools: build c2v in non verbose mode by default 2022-06-20 16:03:39 +03:00
Delyan Angelov fa2e8d8459
tools: use os.system for the c2v runs to monitor the progress more easily 2022-06-20 15:50:38 +03:00
Delyan Angelov 0e4198f23b
tools: fix `v vet file.v` for `return if x { y // comment } else { z }` 2022-06-20 13:29:22 +03:00
yuyi cf1fc6f090
ast: fix array of reference sumtype appending (#14797) 2022-06-20 12:23:53 +03:00
Alexander Medvednikov 924239026c pref: disable gc for translated code 2022-06-19 20:07:45 +03:00
Alexander Medvednikov bc60b0d1a3 builder: add -c when building object files 2022-06-19 19:57:52 +03:00
Alexander Medvednikov d215618f4c sokol: mark pub structs 2022-06-19 19:47:47 +03:00
yuyi de136f6baf
checker: improve pub struct check (fix #14446) (#14777) 2022-06-19 17:42:22 +03:00
Delyan Angelov 37ef1ee453
tools: do show the output of c2v, when it fails 2022-06-19 17:08:21 +03:00
Delyan Angelov 7b1ade237b
tools: fix the first run of `v translate hw.c` 2022-06-19 16:19:56 +03:00
Delyan Angelov b9cb56572f
ci: use VTEST_JUST_ESSENTIAL=1 for the -cstrict test-self task in ubuntu-clang too 2022-06-19 16:08:24 +03:00
Alexander Medvednikov 6875a173ec cmd: enable `v translate`, download and install c2v 2022-06-19 15:52:42 +03:00
Delyan Angelov 97be840a6d
ci: use VTEST_JUST_ESSENTIAL=1 for the ubuntu -cstrict gcc task (prevent 2 hour runs) 2022-06-19 13:29:36 +03:00
lemon e0310964d9
native: initial support for `defer` (#14779) 2022-06-18 23:51:31 +03:00
Alexander Medvednikov 10051e005a parser, cgen: temporary prefix ++ for translated code 2022-06-18 13:30:47 +03:00
wahur666 18dfaf6164
tools: handle fn attributes/comments more robustly, when `v missdoc` is run (#14774) 2022-06-18 11:02:39 +03:00
yuyi 01fdd5d07f
cgen: add a minor optimisation for array.push_many (#14770) 2022-06-17 09:44:13 +03:00
Alexander Medvednikov b89617726c pref: is_o 2022-06-16 20:51:21 +03:00
Louis Schmieder 5df3d8ac75
orm: mysql fixes (#14772) 2022-06-16 20:19:49 +03:00
Alexander Medvednikov fb5a40d1c8 builder: handle linker errors when building .o files 2022-06-16 15:19:13 +03:00
yuyi 26714fadc5
ast, checker, cgen: improve sorting globals and consts (#14769) 2022-06-16 14:32:41 +03:00
Alexander Medvednikov 9c72b85f72 checker: temporary c2v struct init fix 2022-06-16 14:24:17 +03:00
Danilo Lekovic df239b9208
doc: fix 'specifing' typo (#14768) 2022-06-16 11:12:58 +03:00
yuyi f2962c34dd
cgen: format module_init generated c code (#14764) 2022-06-16 11:01:17 +03:00
Delyan Angelov 205221074c tools: support `v watch -k run examples/gg/rectangles.v` (keep a program running) 2022-06-15 18:00:10 +03:00
yuyi 0c1708db23
cgen: minor cleanup in stmt() (#14763) 2022-06-15 17:44:00 +03:00
yuyi 5135952c9c
v.util: add a retry loop for tool compilation in launch_tool() (#14760) 2022-06-15 11:59:53 +03:00
yuyi 7f38b92ca8
cgen: simplify sorting globals and consts (#14761) 2022-06-15 11:56:17 +03:00
yuyi 7c50d276c7
ast: minor cleanup in is_comptime_type() (#14759) 2022-06-14 14:21:45 +03:00
lemon e4e858b132
transformer: fix a bug with string literal length (#14757) 2022-06-14 12:42:45 +03:00
yuyi 6d8a0ad15d
ast, checker, cgen: sort consts with call expr (fix #14748) (#14755) 2022-06-14 10:50:20 +03:00
Spydr 2f1a896d18
native: integer-to-string conversion (#14758) 2022-06-14 00:35:25 +03:00
Leo Developer 67716b5b59
cgen: fix comptime if attributes for `test_` functions (#14756) 2022-06-13 21:22:25 +03:00
yuyi 5efa67906c
cgen: sort const array init order (fix #14748) (#14749) 2022-06-13 21:09:24 +03:00
yuyi 3535927bcd
parser: correct error message for seclector_expr_assign.vv (#14747) 2022-06-12 20:29:54 +03:00
Delyan Angelov 139c34c07d
gg: optimise app.gg.show_fps() (cache ctx.text_size() results, round frame to int without interpolation, center text inside the background rectangle) 2022-06-12 16:07:00 +03:00
Delyan Angelov 4682e17ac1
gg: fix `v -d show_fps run examples/gg/stars.v` 2022-06-12 15:17:04 +03:00
Delyan Angelov 7e06203da8 gg: support `-d show_fps` for all gg apps 2022-06-12 14:20:32 +03:00
Delyan Angelov ff8e286c88
compress.gzip: support `gzip.decompress(data, verify_length: false, verify_checksum: false)?` 2022-06-12 11:25:01 +03:00
Spydr 5c104cf981
native: implement `neg()` for arm64 (#14745) 2022-06-12 09:42:39 +03:00
Spydr 8fa1e30dd2
native: int-to-string conversion detecting zeros and negative values (#14743) 2022-06-11 21:20:13 +03:00
Alexander Medvednikov f08266ab66
doc: autofree/gc update 2022-06-11 20:44:28 +03:00
Joe Conigliaro f3351b6a29
pref: maintain order of 'debug' in compile defines as mod cache key depends on it 2022-06-12 02:22:04 +10:00
Delyan Angelov 5cea8d30fa
ci: make crun_test.v more robust by reducing the tested gap from 5x to 4x 2022-06-11 18:44:02 +03:00
yuyi a538ab7e8c
cgen: minor cleanup for sort globals and consts (#14742) 2022-06-11 18:42:22 +03:00
yuyi cdf4ffc513
cgen: sort globals and consts definitions (#14739) 2022-06-11 17:17:49 +03:00
lemon c7a619d16e
native: support `else`, `break`, `continue` (#14738) 2022-06-11 11:50:19 +03:00
Dialga da7a166708
v.pkgconfig: fix duplication in short flags to the standalone pkgconfig binary (#14740) 2022-06-11 11:06:55 +03:00
spaceface 26d051475a
cgen: ensure closures are kept alive when using the GC (#14736) 2022-06-10 19:48:50 +03:00
Delyan Angelov b27b6b2047
tools: let `v gret` make an easily visible diff.png image after regressions, and upload it too, to make CI failures easier to diagnose 2022-06-10 15:38:50 +03:00
yuyi fcaf529228
parser, checker: check undefined ident in if expr using generic type name (#14734) 2022-06-10 11:57:26 +03:00
Larpon 690a8422d1
vcomplete: add `-no-parallel` to flag completions (#14735) 2022-06-10 11:57:12 +03:00
Delyan Angelov f4869bcdc6 ci: add `apt-get update` before `apt-get install` in gg-regressions 2022-06-10 11:50:30 +03:00
Delyan Angelov ea71ea3ec1
examples: speed up mandelbrot.v a little, increase iterations/details too 2022-06-09 20:10:00 +03:00
yuyi 922f003729
cgen: fix fixed array global variable (fix #14712) (#14730) 2022-06-09 16:53:19 +03:00
Larpon be23ddc253
ci: remove `VFLAGS: -gc none` from vab runs (#14731) 2022-06-09 15:37:53 +03:00
yuyi 784361f153
checker: fix generic method on aliases receiver type (#14729) 2022-06-09 15:36:31 +03:00
Delyan Angelov e1360ccf8c
ci: add `VTEST_JUST_ESSENTIAL=1 ./v test-self` mode. Use it for alpine-docker-musl-gcc . 2022-06-09 15:26:52 +03:00
Ben 39e54a508b
os: correct description of windows_volume function (#14726) 2022-06-09 10:56:58 +03:00
spaceface 4ed9780b80
all: enable `-gc boehm` by default (#14577) 2022-06-09 00:44:29 +03:00
yuyi e6580fefaa
ast: cleanup in generic_insts_to_concrete() (#14724) 2022-06-08 23:17:03 +03:00
Spydr 8563696476
native: added new helper functions (#14723) 2022-06-08 23:16:15 +03:00
Larpon f58e5a94c2
gg: fire resize event before init if necessary on Android (#14725) 2022-06-08 21:43:20 +03:00
Ben c6b1c8d07a
os: add windows_volume function (#14721) 2022-06-08 21:26:24 +03:00
Mikey 5ac9b5c9f1
term.ui: don't print event data in readme example (vlang#14719) (#14720) 2022-06-08 09:36:22 +03:00
Delyan Angelov 4b3c3d9082
checker: add error for `if c >= A && c <= Z {` in non generic functions 2022-06-07 20:43:31 +03:00
Larpon 96a9faf2fd
strings: add split_capital (#14716) 2022-06-07 18:43:06 +03:00
David Valdespino Pavon 1d462136bc
net.http: cookie parsing fixes (#14420) 2022-06-07 12:52:43 +03:00
Larpon 8027919285
ci: update vab install (vlang/vab#176) (#14713) 2022-06-07 12:51:43 +03:00
Delyan Angelov 82594c0156
v.vcache: improve the output of `-d trace_usecache_n` 2022-06-07 12:39:30 +03:00
Delyan Angelov a942ecf737
v.vcache: support `-d trace_usecache_n` too (less verbose tracing for just the initialisation of CacheManager) 2022-06-07 12:24:53 +03:00
Delyan Angelov 82d23dedf1
builtin: add flush_stdout and flush_stderr to builtin.js.v, for feature parity with builtin.c.v 2022-06-07 12:15:35 +03:00
yuyi 7780f56c31
cgen: fix cast to generic interface (#14708) 2022-06-07 08:32:25 +03:00
ChAoS_UnItY 73b59c7b16
cgen: fix none literal str() function calling (#14704) 2022-06-07 01:29:27 +03:00
yuyi abf35270cf
checker: fix json decoder with generic struct (#14700) 2022-06-06 19:25:02 +03:00
ChAoS_UnItY ce26d5bc5c
cgen: fix mutable receiver type calling mapping function causes C error (fix #14230) (#14696) 2022-06-06 18:34:04 +03:00
Delyan Angelov 778fe2cde0
ast: use `[direct_array_access]` for `attrs []Attr` lookup methods 2022-06-06 14:43:04 +03:00
Delyan Angelov 6398043094
cgen: fix missing function names in declarations on `[c2v_variadic][c: xyz]fn deh_fprintf(fstream &C.FILE, fmt &i8)` 2022-06-06 14:33:24 +03:00
Alexander Medvednikov 7f67981637 checker: allow literal args as references in translated code 2022-06-06 13:24:36 +03:00
yuyi 8a2236d3f8
cgen: fix generic interface with non-generic method (#14694) 2022-06-06 12:30:48 +03:00
Alexander Medvednikov e89a6269e4 checker: do not require fn main when building an object file 2022-06-06 12:29:57 +03:00
yuyi ce771876a3
cgen: fix nested map index check (fix #14683) (#14687) 2022-06-06 06:29:22 +03:00
ChAoS_UnItY df80b33dc0
cgen: fix array init with it (fix #14679) (#14680) 2022-06-05 19:41:54 +03:00
Leo Developer 3a90d8ef14
compress: add a new module `compress.gzip` too (#14686) 2022-06-05 18:53:45 +03:00
Ikko Ashimine 7b25957a26
builtin: fix typo in array.v (#14688) 2022-06-05 18:49:40 +03:00
ChAoS_UnItY b000728845
compress.gzip / deflate: rename gzip module into deflate module (#14682) 2022-06-05 08:48:38 +03:00
yuyi 4cf6abd99d
checker: check using literal argument as reference parameter (#14674) 2022-06-05 08:44:35 +03:00
ChAoS_UnItY f6ebbc99cd
cgen: fix array type as interface (fix #14677) (#14681) 2022-06-05 05:05:48 +03:00
yuyi 5d429140a4
json: fix json decode with missing map type field (#14678) 2022-06-04 20:27:11 +03:00
Wertzui123 d71fd04c81
thirdparty/sokol: apply speaker/headset bug fix from latest upstream sokol_audio.h (#14676) 2022-06-04 20:24:07 +03:00
Delyan Angelov 3c5ae41712
examples: simplify the shebang in the v_script.vsh example 2022-06-04 20:15:39 +03:00
Delyan Angelov 3ac3375b43
cgen: fix `for (int i = 0; i < 10; i++, a++) {` (multiple expressions in the inc part) 2022-06-04 20:03:59 +03:00
Delyan Angelov 82eb495617 ci: on windows-msvc, skip const_fixed_array_containing_references_to_itself_test.v 2022-06-04 13:05:27 +03:00
Delyan Angelov f2171b4148 ci: fix macos clang failures with const_fixed_array_containing_references_to_itself_test.v 2022-06-04 09:15:37 +03:00
Delyan Angelov 4cfff58fdf
checker: allow for references to fixed array consts inside their initialisation `const a = [ ... &a[0] ...]!` 2022-06-04 09:04:12 +03:00
Alexander Medvednikov a8461a900d vweb: use http.Cookie 2022-06-04 06:52:46 +03:00
yuyi 66572d5ead
ast: cleanup is_lit() (#14672) 2022-06-03 21:02:36 +03:00
Delyan Angelov c15d1c6e7e
cgen,ci: fix cast_bool_to_int_test.v on windows-tcc 2022-06-03 20:53:10 +03:00
Delyan Angelov 6f9070e06d cgen: do not initialise externally declared globals (with -cstrict with [c_extern]). 2022-06-03 19:14:01 +03:00
Delyan Angelov dbaecdc058
cgen: simplify int(bool_var) casts; support [c_extern] tag for global declarations 2022-06-03 18:48:08 +03:00
yuyi daa94de93f
cgen: fix autofree_variable() (fix #14576) (#14602) 2022-06-03 17:41:30 +03:00
yuyi dcbd8d6405
cgen: fix if expr with optional method call (#14600) 2022-06-03 15:57:39 +03:00
ChAoS_UnItY 65066098d8
compress: Add gzip module & refactor compress & compress.zlib module (#14599) 2022-06-03 09:00:11 +03:00
yuyi 251716fa0e
vrepl: fix error for exitasdfasdf in repl (fix #14593) (#14598) 2022-06-02 19:59:57 +03:00
Delyan Angelov 9f7656f328
ci: vfmt vlib/v/checker/check_types.v 2022-06-02 19:02:34 +03:00
Delyan Angelov c892b3203e
checker: speed up check_expected_call_arg, by only calling Table.type_to_str on errors 2022-06-02 18:58:20 +03:00
Hunam 41414b5d5f
vlib: add `net.http.mime` (#14516) 2022-06-02 18:07:25 +03:00
Delyan Angelov aae5b9fb95
ast.table: cache the returned values of Table.type_to_str_using_aliases/2
This results in 9% speedup of the checker stage for V itself.
2022-06-02 17:53:30 +03:00
Delyan Angelov ed759b2ec9
ci: vfmt vlib/v/parser/parser.v 2022-06-02 15:55:13 +03:00
Delyan Angelov 031629faa1
tools: add cmd/tools/measure/scanner_speed.v and cmd/tools/measure/parser_speed.v 2022-06-02 13:50:25 +03:00
Delyan Angelov 9a0ec7f367
strings: update docs for .str() and for .free() 2022-06-02 10:41:32 +03:00
yuyi 545eaae77b
ast: fix IfExpr.str() (#14595) 2022-06-02 10:28:31 +03:00
Alexander Medvednikov 8b0e843cb8 checker, cgen: c2v variadic fixes 2022-06-02 09:35:25 +03:00
yuyi 10fb16e00b
parser: fix optional with multiple statements (#14592) 2022-06-02 08:23:16 +03:00
Claudio Cesar de Sá 5bf246fce6
examples: some new graphs algorithms and improving 2 others (#14556) 2022-06-02 07:11:29 +03:00
Ben e201665e92
os: fix file_ext function (#14566) 2022-06-02 07:09:46 +03:00
Wertzui123 f971da9a93
help: add Windows to the list of supported native backends in `v help build-native` (#14589) 2022-06-02 07:08:46 +03:00
ChAoS_UnItY a95cdac635
cgen: fix type not being unaliased (fix #14568) (#14591) 2022-06-02 06:21:01 +03:00
yuyi 55951e0943
checker: minor cleanup in if_expr() (#14584) 2022-06-02 06:20:09 +03:00
Hunam d0a1608ede
ci: re-enable Go2V test suite (#14588) 2022-06-02 06:19:38 +03:00
yuyi 33a2d00445
cgen: fix fixed array of aliases struct (#14583) 2022-06-01 16:56:12 +03:00
Delyan Angelov bf70f0b436
v: add support for `v crun examples/hello_world.v`, use crun mode for .vsh files by default. (#14554) 2022-06-01 14:47:52 +03:00
Delyan Angelov c91b646372
examples: document how to produce the shared library, needed for a standalone run of examples/dynamic_library_loading/use.v 2022-06-01 13:58:49 +03:00
yuyi 786045c7da
parser: fix comptime if script mode (fix #6419) (#14578) 2022-06-01 13:27:27 +03:00
Delyan Angelov 5a2c271bd4
cgen: do not #include signal.h, on -os wasm32 and -d no_segfault_handler 2022-06-01 13:21:22 +03:00
Delyan Angelov 2fa64f1471
ci: skip embed_file_test.v for now 2022-06-01 12:06:02 +03:00
yuyi fefb9643b2
checker, cgen: fix array index optional with if expr (#14575) 2022-06-01 09:18:59 +03:00
Delyan Angelov 846ddfd728
v: always embed file data of \$embed_file(file) constructs, even without -prod, unless `-d embed_only_metadata` is given. 2022-06-01 09:08:18 +03:00
Alexander Medvednikov f40c30c3dc cgen: fix goto label 2022-06-01 06:34:04 +03:00
Alexander Medvednikov c54c9b817c cgen: c2v infix fix 2022-06-01 06:14:28 +03:00
Larpon 84e375e38a
toml: update readme with value_opt() usage (#14569) 2022-05-31 19:02:33 +03:00
yuyi 80cc88427b
scanner: minor cleanup in scanner.v (#14565) 2022-05-31 11:52:47 +03:00
playX db34adaec8
builtin.js: fix string.int method (#14564) 2022-05-31 11:52:11 +03:00
Delyan Angelov dc30089c74 v.util, v.builder: fix util.module_is_builtin on macos with -usecache 2022-05-31 09:30:45 +03:00
Ben 4ffdcf8058
os: add existing_path function (#14536) 2022-05-31 06:32:12 +03:00
Delyan Angelov 928dafeb6d
strconv: make f64_to_str_lnd1 public (fix building vlang/coreutils printf) 2022-05-30 22:14:22 +03:00
Delyan Angelov fc64f09f0b
crypto.md5: improve performance of md5.blockblock_generic 2022-05-30 21:56:39 +03:00
Delyan Angelov 0f3b2c2ae7
builtin: use C.fwrite (buffered) for _write_buf_to_fd (#14558) 2022-05-30 19:15:05 +03:00
Delyan Angelov 58ebc0680e
builtin: fix sporadic linking failures on `v -cc gcc -gc boehm examples/hello_world.v` 2022-05-30 15:17:01 +03:00
yuyi 844ba2a177
checker: vfmt overload_return_type.vv (#14557) 2022-05-30 13:49:13 +03:00
Hunam 78d1b7f4ef
net.http: `Response.text` -> `Response.body` (#14478) 2022-05-29 20:27:18 +03:00
yuyi 2c5febe25e
scanner: fix string interpolation with inner curly braces (fix #12242) (#14553) 2022-05-29 19:28:23 +03:00
yuyi 79d861ad4f
parser: fix cast or dump arguments ending with comma (#14552) 2022-05-29 09:15:55 +03:00
Delyan Angelov 63d15086e7 docs: document explicitly, that maps support `if v := m[k] {` too 2022-05-28 21:36:13 +03:00
Delyan Angelov c006d5c242
cgen: add support for `v -cmain SDL_main sdl_example.v` 2022-05-28 21:16:48 +03:00
yuyi c0ef6dbde8
cgen: fix cross assign in closure (#14549) 2022-05-28 20:47:54 +03:00
yuyi 7dcc19df55
ast: fix call_expr.str() with propagate_option or propagate_result (#14550) 2022-05-28 20:47:29 +03:00
Delyan Angelov c6a6eb9a3c
ci: temporary workaround for cross assignment in a closure leading to cgen error 2022-05-28 13:21:59 +03:00
yuyi b8e8768928
parser, cgen: fix cross assign with parentheses (#14545) 2022-05-28 12:02:17 +03:00
yuyi a46cf10e92
checker: fix declare assign literal with closure (#14544) 2022-05-28 11:50:37 +03:00
Delyan Angelov 4894f61998
toml: add `pub fn (d Doc) value_opt(key string) ?Any {` and some tests for toml.parse_dotted_key/1 2022-05-28 09:18:18 +03:00
yuyi a971b9a99a
parser: fix match expr case with struct init (#14538) 2022-05-27 18:51:40 +03:00
Larpon f3e7f24ee6
tools: implement `v missdoc --diff oldv newv` (#14537) 2022-05-27 18:19:06 +03:00
spaceface 52a3e5e780
cgen: fix a race condition in the closure implementation (#14532) 2022-05-27 17:35:02 +03:00
Delyan Angelov f7995c8916
checker: fix error position in `fn f() int { return 1,2 }` 2022-05-27 16:53:24 +03:00
Delyan Angelov 36cb552918
ci: vfmt cmd/tools/vpm.v 2022-05-27 15:22:47 +03:00
Delyan Angelov 156aa661ee
tools: fix `v install https://github.com/nedpals/vex.git` (fix #14483) 2022-05-27 15:21:01 +03:00
Louis Schmieder a83ac948a0
orm: document & fix pg (#14533) 2022-05-26 22:53:09 +03:00
yuyi b97ef09b2d
checker: cleanup checker.v (#14530) 2022-05-26 22:52:42 +03:00
Delyan Angelov bb6ef8bba8
cgen: fix parallel cgen for json encoding of struct fields that have default values 2022-05-26 16:55:44 +03:00
Delyan Angelov 8c969efe6b
tests: make json_test.v less noisy, to see errors easier 2022-05-26 15:27:54 +03:00
Wertzui123 1017335365
x.ttf: fix typo in README (#14528) 2022-05-26 11:17:15 +03:00
yuyi 3849cdcecc
fmt: fix fn return types list ending with comma (#14529) 2022-05-26 04:20:22 +03:00
Delyan Angelov 410b57b2fa
all: add support for struct field deprecation (#14527) 2022-05-26 00:44:18 +03:00
Larpon 95cc535fc7
ci: use missdoc as subcmd (#14524) 2022-05-25 19:07:07 +03:00
Larpon 9f5e999b4a
tools: add v missdoc --verify mode (#14525) 2022-05-25 19:06:11 +03:00
Larpon 6c08af63ff
embed_file: rename debug_embed_file_in_prod -> force_embed_file (#14523) 2022-05-25 18:26:17 +03:00
yuyi 59e57f0c62
fmt: fix fmt of Ok<[]Token>{[]} (#14522) 2022-05-25 15:17:30 +03:00
kahsa dd8c96f6bc
net.html: use `-d debug_html` instead of `-g`, prevent undesired output, while debugging user programs (#14521) 2022-05-25 11:23:56 +03:00
Delyan Angelov 31c234485a
cgen: split keys and values in generated new_map_init calls into separate lines 2022-05-25 10:26:17 +03:00
yuyi e19ac0c4a7
checker: check fn call with argument mismatch (#14519) 2022-05-25 09:00:26 +03:00
yuyi 79a75c5ac0
parser: fix fmt error for json decode (#14520) 2022-05-25 08:59:22 +03:00
yuyi 0eb3f8854d
fmt: fix file with just imports (fix #14267) (#14513) 2022-05-24 20:14:08 +03:00
Ben f431020764
os: minor clean ups on filepath.v (#14506) 2022-05-24 11:29:32 +03:00
yuyi f35f7fe997
fmt: fix using rand.seed() when import rand and rand.seed (#14511) 2022-05-24 11:21:49 +03:00
yuyi a5b98cb267
parser: check fn decl multi return types without parentheses (#14508) 2022-05-24 05:15:31 +03:00
yuyi 5ade39f8db
cgen: fix sizeof('str') and sizeof(r'str') (#14507) 2022-05-24 05:14:38 +03:00
Delyan Angelov 953ef1f8c9
pref: add support for `-dump-files -` and for `-dump-modules -` 2022-05-23 19:51:21 +03:00
Delyan Angelov dda49fe735
v.builder: support -dump-c-flags with -cc msvc too 2022-05-23 18:29:39 +03:00
yuyi a3c0a9b791
checker: minor optimization in fn_call() and method_call() (#14503) 2022-05-23 08:00:57 +03:00
yuyi 4ef9e2c05a
parser: fix sizeof(c'str') (fix #14499) (#14502) 2022-05-23 01:59:39 +03:00
Alexander Medvednikov 863eeca2e0 checker: vfmt checker.v 2022-05-23 00:12:37 +03:00
Daniel Däschle 5e95bdc451
checker: allow but deprecate propagating result as option (#14500) 2022-05-23 00:11:29 +03:00
yuyi 7f03b89611
checker: check method call argument type mismatch (#14496) 2022-05-22 22:16:46 +03:00
spaceface ba859c584b
builtin: add static GC support on Windows with TCC (#14497) 2022-05-22 21:25:46 +03:00
Delyan Angelov 5328dabad1
time: simplify some very commonly used t.format methods 2022-05-22 21:09:49 +03:00
spaceface e5ff2ab455
ci: run on all branches on forks (#14498) 2022-05-22 20:19:04 +03:00
yuyi 1f3336c9d3
checker: fix map get anon fn value with mut argument (fix #14479) (#14493) 2022-05-22 16:28:53 +03:00
Alexander Medvednikov 245d28d57a checker: c2v infix fix 2022-05-22 14:53:21 +03:00
Daniel Däschle d3ffd983c8
markused: add _result_ok (#14495) 2022-05-22 14:52:38 +03:00
Subhomoy Haldar 3647fb4def
rand: move dist functions to top module and PRNG interface; minor cleanup (#14481) 2022-05-22 13:21:52 +03:00
Delyan Angelov 64a686f41f examples: speed up mandelbrot.v by using a constant size thread pool, processing smaller chunks 2022-05-22 11:12:16 +03:00
yuyi 50ab2cfd1a
fmt: fix 'strings' name variable call generate auto import (fix #9713) (#14485) 2022-05-21 15:01:58 +03:00
Delyan Angelov 0ceb16f285
v.builder: use /NOLOGO, when building cached object files with msvc 2022-05-21 12:56:24 +03:00
Delyan Angelov c0dcc80e18
cgen: support `-profile -` for _test.v files too 2022-05-21 10:59:01 +03:00
Delyan Angelov a7afb2d1eb
time: remove `import math` dependency, by implementing a simpler version of mceil 2022-05-21 02:04:17 +03:00
Ben 971c55cf30
os: add norm_path and abs_path function (#14435) 2022-05-21 01:16:29 +03:00
Daniel Däschle efc5cab8c3
checker,cgen: allow result if guard (#14474) 2022-05-20 19:34:53 +03:00
Alexander Medvednikov 53c217fe5e cgen: do not generate `_vinit()` for translated .o code 2022-05-20 19:28:37 +03:00
Vincenzo Palazzo 17bba712bd
checker: ban unsafe pointer/fn comparison (#14462) 2022-05-20 18:30:16 +03:00
Daniel Däschle d81fbb1ccd
ci: only run on master (#14476) 2022-05-20 18:27:35 +03:00
Delyan Angelov dd1049f21d
thirdparty: fix typo in atomic.h, cleanup comments. 2022-05-20 14:21:31 +03:00
yuyi 28b0cbddad
parser: check error for script mode that define main function (fix #14467) (#14469) 2022-05-20 14:20:18 +03:00
yuyi 913164bc73
builtin: minor cleanup in string_interpolation.v (#14471) 2022-05-20 14:19:27 +03:00
yuyi bf44572f30
fmt: fix chain calls with comments (#14470) 2022-05-20 11:47:44 +03:00
StunxFS 11bdb04d0c
json: fix struct field default value support (#14304) 2022-05-20 11:22:17 +03:00
Delyan Angelov ca00b59b3f
tests: make potential failures in urllib_test.v more informative 2022-05-20 08:49:56 +03:00
David 'Epper' Marshall 120f31b4d9
math: update documentation (#14457) 2022-05-20 08:45:54 +03:00
David 'Epper' Marshall 23568f19da
url: fix parse (#14456) 2022-05-20 02:58:58 +03:00
crthpl 95d24e543d
checker, cgen: fix shared non-decl assignment (#14466) 2022-05-20 02:58:11 +03:00
yuyi 55e7daa2f9
cgen: simplify auto_str_methods.v (#14463) 2022-05-19 22:29:15 +03:00
crthpl 46f94e8d68
cgen: fix autostr of shared fields (#14455) 2022-05-19 17:00:27 +03:00
Daniel Däschle a52fbc5e51
checker: forbid optional variable (#14460) 2022-05-19 16:04:44 +03:00
yuyi 3291c59ebf
cgen: minor cleanup in auto_str_methods.v (#14461) 2022-05-19 14:02:07 +03:00
Delyan Angelov 634e8c3624
vfmt: keep selective imported names used for generic calls 2022-05-19 12:48:43 +03:00
yuyi 15c62bc8e8
parser: improve error messages of 'for val in array' (#14459) 2022-05-19 11:53:27 +03:00
Delyan Angelov 25812e52f0
ci: use V_CI_CSTRICT=1 consistently for every `v -cstrict test-self` 2022-05-19 11:52:31 +03:00
Delyan Angelov a52590572f
tests: fix the push_work_on_channel.vv output 2022-05-19 11:30:36 +03:00
Delyan Angelov 3d5617c4fa
tests: re-add the disambiguated `for (val in [TokenValue(`+`), TokenValue(`-`)]) {` test 2022-05-19 08:31:03 +03:00
Delyan Angelov 809b1ca3b4
Revert "parser: fix 'val in array' as condition in for stmt (fix #14440) (#14451)"
This reverts commit b482c0512b.
2022-05-19 08:29:30 +03:00
yuyi b482c0512b
parser: fix 'val in array' as condition in for stmt (fix #14440) (#14451) 2022-05-18 20:38:53 +03:00
Delyan Angelov 805a7d9713 ci: skip more .vv files on specific jobs 2022-05-18 20:04:59 +03:00
yuyi 5b96f7e8fd
checker: split up infix.v from checker.v (#14449) 2022-05-18 14:52:53 +03:00
yuyi 4cbfa884c5
cgen: fix another error for 'in array of sumtype' (#14448) 2022-05-18 14:39:35 +03:00
Delyan Angelov f2447a4bd8
tests: do not use -prod for compiling .vv files in vlib/v/checker/tests/ and vlib/v/parser/tests/ 2022-05-18 13:39:57 +03:00
Delyan Angelov 2cc3b74e19
tests: cleanup compiler_errors_test.v using language features (chan), instead of raw `sync.new_channel` and `unsafe { ch.push }` calls 2022-05-18 13:39:56 +03:00
Larpon 9de0c725f6
checker: add test for empty #flag node, (fix #14291) (#14447) 2022-05-18 13:38:58 +03:00
Adam Oates a786c58d0a
os: add `fn user_names()` (#14424) 2022-05-18 13:37:34 +03:00
yuyi 417a6dc506
cgen: fix error for 'in array of sumtype' (#14444) 2022-05-18 08:51:31 +03:00
Larpon 8eea861c93
vcomplete: improve flag completion, add missdoc (#14415) 2022-05-18 08:50:32 +03:00
Delyan Angelov ed17779434
math.big: fix Integer.bit_len() when there are no digits in the number 2022-05-18 08:29:08 +03:00
Delyan Angelov ebac3bebb1
pref: pass -v after a command, to the command only, do not set verbose mode on 2022-05-18 07:03:00 +03:00
playX a608516b82
checker: c2v fixed array fix (#14436) 2022-05-18 02:35:05 +03:00
spaceface b5fb848508
cgen: reduce the closure memory usage (#14437) 2022-05-18 02:34:51 +03:00
Delyan Angelov 65d9c8fa6f
tools: add a vet_known_failing_windows skip list to `v test-cleancode` 2022-05-17 20:19:37 +03:00
Delyan Angelov dfa2d63616
ci: use VJOBS=1 for the macos v test-cleancode task too; cleanup periodic.yml 2022-05-17 19:55:28 +03:00
Delyan Angelov 4e56147223 ci: vfmt builtin_d_use_libbacktrace.c.v 2022-05-17 19:41:57 +03:00
Alexander Medvednikov 2a06290ac7 cgen: fix eq generation for translated code 2022-05-17 15:30:05 +03:00
Ned db4b49a5ca
builtin: print libbacktrace output to stderr, on panics/segfault crash (#14434) 2022-05-17 14:56:34 +03:00
Delyan Angelov da42f0d42b
ci: add an early step 'All code is formatted' to more workflows. 2022-05-17 13:14:08 +03:00
Delyan Angelov 3fc4459485
ci: ignore orm_joined_tables_select_test.v on tasks, that do not have sqlite installed 2022-05-17 12:53:07 +03:00
yuyi 020845f6c3
cgen: fix alias of array that has builtin method (#14432) 2022-05-17 12:26:26 +03:00
yuyi d7b1e57186
v.builder: improve builder error messages (fix #14386) (#14421) 2022-05-17 12:12:20 +03:00
yuyi 60e817ff32
cgen: minor optimization in index_of_array/map() (#14429) 2022-05-17 12:08:44 +03:00
yuyi d6aa85d059
parser: fix panic for parse invalid map type (#14431) 2022-05-17 12:05:10 +03:00
playX 7c6eaa8204
checker: allow to use [n]anyptr as [n]otherptr in check_types (c2v fix) (#14433) 2022-05-17 11:55:04 +03:00
Delyan Angelov 78ab3296c9
checker: fix orm bug, when a joined table field context replaced the original table field context 2022-05-17 11:45:17 +03:00
WoodyAtHome 02c8a6057c
builtin.string: new fn (s string) is_ascii() bool (#14418) 2022-05-17 08:01:03 +03:00
Alexander Medvednikov d10f83ce15 cgen: fix c2v struct eq 2022-05-17 03:39:48 +03:00
playX bc397bb0e1
checker: c2v array fix (#14426) 2022-05-17 00:08:41 +03:00
Delyan Angelov 32dd801201
checker: apply fix for ui suggested by spaceface 2022-05-16 21:33:02 +03:00
Delyan Angelov 9cb8bb2968
Revert "Revert "checker: allow using methods as vars when expecting a ctx arg (#14414)""
This reverts commit e5c7fe3006.
2022-05-16 21:29:47 +03:00
yuyi c624de8523
cgen: fix struct field array index error (#14417) 2022-05-16 19:37:39 +03:00
Delyan Angelov e5c7fe3006
Revert "checker: allow using methods as vars when expecting a ctx arg (#14414)"
This reverts commit 36bec823c2.
2022-05-16 14:19:33 +03:00
Delyan Angelov 39874ae168
clipboard: fix `v -gc boehm run x.v`, where x.v does c.paste() (fix #14281) 2022-05-16 12:54:30 +03:00
yuyi d59f4e9479
ast, cgen: fix generic method with variadic generic argument (#14404) 2022-05-16 12:26:38 +03:00
Larpon ef6225c542
vvet: fix false positive, add test (#14403) 2022-05-16 12:24:21 +03:00
yuyi 0ab4133128
cgen: minor cleanup in struct_init() (#14405) 2022-05-16 12:22:51 +03:00
spaceface 36bec823c2
checker: allow using methods as vars when expecting a ctx arg (#14414) 2022-05-16 12:05:08 +03:00
WoodyAtHome c2b763655d
net.smtp: handle UTF-8 subjects according to RFC 1342 (#14410) 2022-05-16 11:09:36 +03:00
Delyan Angelov 1cf683d482
checker: add a suggestion for misspelled mod.const_name + a test 2022-05-16 10:29:58 +03:00
Delyan Angelov b4c529066a
tests: simplify cmd/tools/modules/testing/common.v 2022-05-16 10:29:57 +03:00
Ben cbb24d34c9
os: fix is_abs_path function for Windows systems (#14397) 2022-05-16 09:59:37 +03:00
yuyi 7fe3ef9a6e
fmt: fix fmt error of anon fn with if expr (fix #14393) (#14413) 2022-05-16 09:48:21 +03:00
Larpon 5068b8b293
ftp: document all public methods (#14408) 2022-05-16 08:52:12 +03:00
Jah-On 02e026e298
clipboard: add `[heap]` tag to the Clipboard structs (#14412) 2022-05-16 08:45:40 +03:00
WoodyAtHome eeff02a8ee
net.openssl: read doesn't block infinitely (#14406) 2022-05-16 08:44:34 +03:00
spaceface c01a8a1737
checker,gen: allow using methods as function pointers (#14407) 2022-05-15 18:28:37 +03:00
Delyan Angelov c2bc9f4960
sync: only run channel_select_test.v when VTEST_RUN_FLAKY=1 2022-05-15 12:43:04 +03:00
crthpl e4065bd57b
checker,cgen: fix if expressions in lock expression (#14384) 2022-05-15 12:31:07 +03:00
David 'Epper' Marshall c28051020a
time: fix calculate_date_from_offset (#14399) 2022-05-15 10:55:24 +03:00
Delyan Angelov b50f7fdc71
ci: simplify ci_sanitized.yml again; use `v.exe fmt -verify vlib/builtin` for windows/msvc instead of `v test-cleancode` 2022-05-15 10:54:31 +03:00
Delyan Angelov c70e18ea8f
ci: add a skip list in compiler_test.v (for tmpl_parse_html.vv) 2022-05-15 10:23:13 +03:00
Delyan Angelov 3a09ccc80a
ci: restore .github/workflows/ to its state at cee7856, when all checks were done 2022-05-15 10:23:12 +03:00
Larpon dd6629e932
examples: fix 2048 scaling on Android (#14380) 2022-05-15 09:14:18 +03:00
David 'Epper' Marshall 8d141878ce
math: cbrt fix (#14395) 2022-05-14 21:06:38 +03:00
Delyan Angelov 67963e0ff2
ci: further cleanup of ci_sanitized.yml 2022-05-14 20:34:01 +03:00
Delyan Angelov 1225a865a3
ci: simplify ci_sanitized.yml 2022-05-14 20:29:56 +03:00
yuyi fe9f97074b
cgen: fix appending struct to interface array (#14388) 2022-05-14 17:49:42 +03:00
Alexander Medvednikov 3adad32355 tmpl: fix a test 2022-05-14 17:48:50 +03:00
Alexander Medvednikov b42c824cdb vweb: simplify @foo by removing V_TEMPLATE rule 2022-05-14 17:46:30 +03:00
Daniel Däschle f0d46413d9
ci: require code to be formatted before everything else (minimise CI queue length) (#14396) 2022-05-14 15:38:15 +03:00
JalonSolov b3e80a3100
examples: add missing v.mod file (#14392) 2022-05-14 14:48:42 +03:00
j. redhead 441637eeb4
checker: fix optionals in infix expression check (fix #14354) (#14390) 2022-05-14 00:54:49 +03:00
Delyan Angelov cee7856c0f
ci: add a quick `v test-cleancode` check, before more costlier tasks 2022-05-13 12:24:11 +03:00
Delyan Angelov 714ce4e7fc
ci: fix .out regression after d407a64 2022-05-13 11:18:17 +03:00
Delyan Angelov c1bafe7a5a
ci: extract v_apps_and_modules_compile.yml 2022-05-13 11:02:24 +03:00
playX 6ec4185017
checker: allow to pass alias to array as a pointer (c2v) (#14389) 2022-05-13 10:17:28 +03:00
Daniel Däschle d407a6449d
parser: fix dollar (closes #14292) (#14378) 2022-05-13 08:30:10 +03:00
Delyan Angelov ed12a5c84c
math.big: reduce memory usage of Integer.str() (free intermediary Integers), optimise some operations using `[direct_array_access]` (#14353) 2022-05-13 08:21:34 +03:00
yuyi 3c95504a35
checker, cgen: fix generic fn with array and fixed array arguments (#14385) 2022-05-13 06:57:48 +03:00
Daniel Däschle d679146a80
fmt: remove space in front of ? and ! (#14366) 2022-05-13 06:56:21 +03:00
Delyan Angelov df029da942
Revert "ci: run `code-formatting` job before everything else (try 2) (#14379)"
This reverts commit 0972e67f72.
2022-05-12 23:29:37 +03:00
Daniel Däschle 0972e67f72
ci: run `code-formatting` job before everything else (try 2) (#14379) 2022-05-12 21:58:11 +03:00
Delyan Angelov 8ef9dc6247
ci: run `v fmt -w vlib/v/checker/fn.v` (fix CI regression after 4952967) 2022-05-12 21:24:12 +03:00
Delyan Angelov 668d1b04d2
parser: make script mode errors more informative, when a top level declaration is encountered, after script mode had already started 2022-05-12 21:14:00 +03:00
Hunam 20139ad756
checker: fix typo (#14368) 2022-05-12 12:23:32 +03:00
playX 4952967366
checker: alias C2V fix (#14377) 2022-05-12 12:19:31 +03:00
yuyi f48f7014f0
checker: check error for generic sumtype types (#14374) 2022-05-12 11:57:57 +03:00
penguindark e93a8766e5
regex: fix #14370, last IST not managed in advance tests (#14372) 2022-05-12 11:49:57 +03:00
Delyan Angelov b7ca4c1668
checker: fix a compiler panic on `fntest()?(&int,&int){return test()?}` 2022-05-12 11:36:32 +03:00
yuyi 8830af5c89
rand: minor cleanup in choose() (#14376) 2022-05-12 11:20:38 +03:00
yuyi 5bc4fea9e0
checker: check error for cast function to string (#14375) 2022-05-12 10:04:38 +03:00
CC 901b8f0c24
builtin: add a map.clear() method (#14373) 2022-05-12 09:43:01 +03:00
spaceface 49382f1f43
gen: make the closure implementation more performant (#14352) 2022-05-12 00:05:14 +03:00
Emily Hudson c19b037880
net: select with deadlines (#14369) 2022-05-12 00:03:48 +03:00
yuyi cd4fa041ff
checker: check generic sumtype declare error (#14367) 2022-05-11 17:39:58 +03:00
Larpon 34a252ef84
os: add `raw_execute` on Windows (#14363) 2022-05-11 16:56:03 +03:00
David 'Epper' Marshall 26b81d68b5
time: update doc comments (#14359) 2022-05-11 16:55:19 +03:00
Larpon 0ec1c8d9f0
szip: expose zip_folder (#14356) 2022-05-11 16:48:41 +03:00
yuyi 3afc7c4c6d
parser: check error for generic struct parameter (#14362) 2022-05-11 13:24:54 +03:00
Delyan Angelov cf536b848b
Revert "strings: reduce time spent in Builder.writeln (very frequently called)"
This reverts commit b53b1cc7cb.
2022-05-11 09:19:37 +03:00
yuyi 8f765ed5f1
checker: minor cleanup and speedups in fn_call() (#14343) 2022-05-10 16:41:47 +03:00
yuyi 5697d4375b
cgen: fix error for printing aliases of multi fixed array (#14348) 2022-05-10 14:03:18 +03:00
yuyi 606d8cfaca
checker: check error for returning aliases of fixed array (#14349) 2022-05-10 14:01:55 +03:00
Isaiah 9e09b709e3
net.http: fix crash on Windows when using Boehm GC (#14351) 2022-05-10 14:00:55 +03:00
yuyi 940c78bdfd
checker: minor cleanup in method_call() (#14342) 2022-05-09 18:01:44 +03:00
Subhomoy Haldar 79f8a3c796
rand: update README.md (#14341)
* update README for rand module

* use concrete values

* make sure code works
2022-05-09 17:59:20 +03:00
StunxFS d24dce8eb3
parser,checker: support `$compile_error('message')` and `$compile_warn('message')` (#14320) 2022-05-09 08:18:26 +03:00
Dialga 4400f9891e
szip: fix extracting dot folders (#13387) 2022-05-09 07:45:36 +03:00
yuyi 8519996201
checker: fix error for match sumtype that referenced before (#14338) 2022-05-09 07:32:51 +03:00
Merlin Diavova 106487d62f
pg: resolve PG string datetime values to V time.Time ones (#14336)
Co-authored-by: Merlin Diavova <md@merlindiaova.org>
2022-05-08 15:37:46 +03:00
David 'Epper' Marshall 650fb493bd
regex: add split (#14329) 2022-05-08 15:21:39 +03:00
Delyan Angelov 084f2867b6
time: let time.parse_rfc3339('2015-01-06T15:47:32.080254511Z') succeed (dockerd timestamps, Go's RFC3339Nano). 2022-05-08 14:54:57 +03:00
WoodyAtHome a0a3499bdc
net.smtp: correct date in smtp body (#14326) 2022-05-08 09:15:45 +03:00
Alexander Medvednikov 0526499d5f tools: hide tcc warning on macos for now 2022-05-08 08:01:55 +03:00
Merlin Diavova f8747d05dc
pg: add type 18 for pg boolean data type (#14335) 2022-05-08 07:17:43 +03:00
StunxFS d5e70552eb
checker: check error for `json.decode` (fix #6732) (#14305) 2022-05-08 07:17:11 +03:00
David 'Epper' Marshall aef95721a4
strings: builder: add clear (#14328) 2022-05-08 07:15:42 +03:00
yuyi b04d46770b
ast, checker, cgen: fix error for generic method with generic fn type argument (fix #14239) (#14333) 2022-05-07 20:22:20 +03:00
yuyi 724e7f037a
cgen: fix error for if cond with optional expr (#14334) 2022-05-07 20:20:00 +03:00
David 'Epper' Marshall a91226c376
docs: cleanup (#14327) 2022-05-07 20:18:42 +03:00
Delyan Angelov b53b1cc7cb
strings: reduce time spent in Builder.writeln (very frequently called) 2022-05-07 12:55:41 +03:00
Delyan Angelov 7ecd65221e
v.util: support -d trace_cached_read_source_file 2022-05-07 12:55:41 +03:00
Delyan Angelov 56cf0b0a2e
builtin: inline manually isnil calls in array.push_many (very frequently called) 2022-05-07 12:55:40 +03:00
Delyan Angelov 7f974a275a
docs: fix `teh` typo 2022-05-07 12:55:40 +03:00
Delyan Angelov f956acd2f6
ci: restore the `v -autofree .` step for gitly (gitly now has a workaround) 2022-05-07 12:55:40 +03:00
Delyan Angelov 9e8e364493
ci: comment out the go2v testing step for now 2022-05-07 12:55:39 +03:00
Alexander Medvednikov ca42ace367 Revert "checker: remove more unnecessary `void` errors"
This reverts commit 89c1e7f980.
2022-05-07 11:03:12 +03:00
Alexander Medvednikov 35cfa0da7c doc: closures work on arm64 too 2022-05-07 11:02:53 +03:00
playX 6a6c005dc0
checker: c2v fixes (#14332) 2022-05-07 09:50:41 +03:00
Alexander Medvednikov 9fb8de14dd
doc: closures now work on Windows 2022-05-07 09:49:33 +03:00
Alexander Medvednikov 89c1e7f980 checker: remove more unnecessary `void` errors 2022-05-07 09:09:18 +03:00
yuyi 70184ad1f8
scanner: minor simplification in scanner.v (#14331) 2022-05-07 08:30:15 +03:00
Alexander Medvednikov 14f06ead1b cgen: fix c2v consts; enum_decl() 2022-05-07 00:58:37 +03:00
yuyi 621574c12a
checker: fix error for generic method on nested struct (#14322) 2022-05-07 00:51:04 +03:00
Hunam 0699f324b5
builtin: add `map.values()` (#14301) 2022-05-06 20:42:01 +03:00
Lathanao ce99a306c0
net.http: make parse_form return POST requests with json data as a map with a `json` key, containing the json payload (#14289) 2022-05-06 20:23:36 +03:00
StunxFS 87de6df0e6
docs: update keyword list (#14319) 2022-05-06 20:17:45 +03:00
Ekopalypse 2027a1969b
v.builder: harmonise the default settings of the different Windows compilers (#14314) 2022-05-06 19:28:13 +03:00
Daniel Däschle 76cdf75299
builtin,cgen: rename `Option` to `_option` (#14317) 2022-05-06 19:25:54 +03:00
yuyi 45fe87c9e3
checker: minor cleanup in fn_call() (#14307) 2022-05-05 21:15:54 +03:00
yuyi 3091f31019
checker: check for optional argument in dump() (#14316) 2022-05-05 21:15:22 +03:00
Claudio Cesar de Sá 634796ae42
examples: 2 new examples for graph algorithms (topological sorting) (#14303) 2022-05-05 18:08:08 +03:00
Andréas Livet 9fde5b067b
docs: add missing function names in the `builtin` example doc comments (#14318) 2022-05-05 17:22:25 +03:00
Daniel Däschle 89fe82b732
checker: fix returning error on reference results (#14313) 2022-05-05 17:02:49 +03:00
yuyi b6058bfd6e
parser, checker: fix generic method on nested struct (fix #14089) (#14310) 2022-05-05 11:24:20 +03:00
playX 8afdb1c3ef
checker: c2v: allow passing fixed array as pointer to functions; bool <-> int (#14309) 2022-05-05 11:23:57 +03:00
StunxFS 7499506cf8
.gitignore: minor cleanup (#14279) 2022-05-05 10:17:24 +03:00
Delyan Angelov 785e9af8f1
ci: comment out the `v -autofree .` step for gitly temporarily 2022-05-05 09:20:08 +03:00
Delyan Angelov 7170a09382
vfmt: fix stackoverflow on long nested infix expressions 2022-05-05 07:41:43 +03:00
Delyan Angelov 01c1892995
tools: fix building `vdoctor.v` with `v build-tools` 2022-05-04 23:30:44 +03:00
Delyan Angelov a6b3e5d6a5
ci: wrap the too long line in README.md that failed `./v check-md -hide-warnings .` 2022-05-04 21:19:57 +03:00
Ned 76a7354506
builtin: add libbacktrace as option for generating stack traces (#14277) 2022-05-04 21:17:05 +03:00
yuyi 4242e7610f
checker: add comptime_selector() (#14286) 2022-05-04 19:25:58 +03:00
yuyi e2aa5c9b3f
parser: make peek_token_after_var_list() private (#14288) 2022-05-04 19:25:45 +03:00
Ikko Ashimine 223b96a59a
builtin: fix typo in array_bare.v (#14299) 2022-05-04 19:25:17 +03:00
Delyan Angelov 1a4d9017e2
builtin: improve support for large arrays (`[]int{len: 1_000_000_000}` now works), fix an arr.repeat() bug (#14294) 2022-05-04 18:42:06 +03:00
Alexander Medvednikov af8be14639
readme: minor github markdown fix 2022-05-04 18:06:41 +03:00
yuyi ac90a2b53d
checker: check error for fn call argument mismatch (fix #14280) (#14283) 2022-05-04 12:13:22 +03:00
playX 3bd6455178
checker: allow rune->any int and vice versa when translated (#14285) 2022-05-04 12:08:34 +03:00
Alexander Medvednikov 3d4b8dffdf checker: temporary c2v const fix 2022-05-04 08:28:27 +03:00
yuyi f321422964
checker, cgen: check comptime selector that has no field name (#14282) 2022-05-04 07:06:52 +03:00
Alexander Medvednikov 1e9156fd71 checker: c2v rune comparison fix 2022-05-04 06:49:45 +03:00
yuyi 3732db2bcc
cgen: cleanup in gen_array_contains_methods() (#14274) 2022-05-03 20:46:07 +03:00
playX 146051b231
checker: allow fixed array to pointer and vice versa when translated (#14275) 2022-05-03 20:44:45 +03:00
Delyan Angelov 04a77c731e
tests: add `// vtest flaky: true` to atomic_test.v 2022-05-03 20:42:12 +03:00
yuyi 63eacede95
checker: check argument mismatch of array.filter/all/any() (#14273) 2022-05-03 16:56:18 +03:00
Hunam 6da300428e
doc: add JS backend mention (#14265) 2022-05-03 12:51:12 +03:00
yuyi 276bd8060c
cgen: fix error for fixed array in operate (#14269) 2022-05-03 12:45:04 +03:00
Delyan Angelov 0e5c1cee48
builtin: improve musl/Alpine support (define weak backtrace/backtrace_symbols/backtrace_symbols_fd symbols) (#14250) 2022-05-03 09:17:53 +03:00
Delyan Angelov 4da2908d63
vdoc: fix panic on empty `//` comment on `v doc -f html file.v`; turn `expected code block after empty example` to a warning 2022-05-03 00:02:12 +03:00
StunxFS cf92224248
cleanup: delete x.v in project root folder (#14260) 2022-05-02 22:58:14 +03:00
Delyan Angelov ab1c265679
builtin: add missing panic_result_not_set/1 callback function. 2022-05-02 22:40:26 +03:00
spaceface db185598d2
checker: refactor comptime_if_branch (#14259) 2022-05-02 22:24:20 +03:00
yuyi 990afe37e1
checker: fix a bug in generics array init (#14258) 2022-05-02 16:18:33 +03:00
yuyi d72a25098a
parser: minor cleanup in interface_decl() (#14257) 2022-05-02 16:17:46 +03:00
yuyi 25c1b174ca
checker: fix generic fn infering fn type argument (fix #14243) (#14256) 2022-05-02 16:17:27 +03:00
yuyi b9cf2db6a8
parser: fix inline array's element access (#14253) 2022-05-02 16:16:32 +03:00
playX afbe6bf3a2
cgen: fix const decl gen when translated (#14255) 2022-05-02 15:01:59 +03:00
Isaiah a4fd349cf1
builder: allow `-compress` to work on windows too, when `upx` is installed (#14252)
Allow `-compress` flag on Windows if upx is installed. If upx not installed, same behavior as on linux/mac
2022-05-02 14:28:31 +03:00
yuyi 968d2b4654
cgen: fix fixed array init with `it` (#14251) 2022-05-02 02:00:45 +03:00
spaceface 332e821518
checker, gen: add support for a [minify] struct attribute (#14247) 2022-05-02 01:59:17 +03:00
Delyan Angelov aed2d0caf2
make files: add a `make check` target, that runs `v test-all` locally 2022-05-01 13:38:30 +03:00
David 'Epper' Marshall 91c1157810
time: relative update (#14240) 2022-05-01 10:47:05 +03:00
Daniel Däschle ec92d467d1
cgen: fix unsafe return error (#14233) 2022-04-30 17:31:28 +03:00
playX 0b54196962
checker: allow pointer index for translated code (#14231) 2022-04-30 17:30:55 +03:00
Daniel Däschle 9f8a34a528
all: rename result to _result (#14232) 2022-04-30 17:10:30 +03:00
Delyan Angelov 63d413f93c
tools: support `v missdoc .` instead of `v run cmd/tools/missdoc.v .` 2022-04-30 16:12:39 +03:00
Delyan Angelov c0b37409d2
tools: support a `v vet -p file.v` option that will warn about private functions with missing documentation 2022-04-30 16:09:30 +03:00
Delyan Angelov 8da42bfc85 tests: fix `./v -W build-tools` CI failure 2022-04-30 13:49:36 +03:00
Delyan Angelov 5277ce7dce
tests: support for marking _test.v files with `// vtest flaky: true`, to reduce false positives from the CI 2022-04-30 13:30:02 +03:00
David 'Epper' Marshall a2338dbb7c
docs: document more `builtin` functions/methods (#14229) 2022-04-30 12:31:23 +03:00
Delyan Angelov dcdfdf4dd8
tools: make `v up` more informative on failure 2022-04-30 10:11:02 +03:00
spaceface dab649ec8a
cgen: rewrite the closure implementation (#14223) 2022-04-30 09:32:46 +03:00
Alexander Medvednikov ce31a01a70 checker: allow voidptr arithmetic in translated code 2022-04-30 05:52:37 +03:00
yuyi cd30b6ea82
parser: make sure interface field names use uppercase letters (#14228) 2022-04-30 05:29:33 +03:00
Daniel Däschle 08fd0ce0de
all: basic implementation of result type (#14140) 2022-04-30 01:59:14 +03:00
StunxFS db185e6580
checker: check for reserved type names in `for in` (fix #14072) (#14212) 2022-04-30 01:25:29 +03:00
Benjamin Thomas 48eb40cd2c
doc: suggest a basic auto-reload setup (#14216) 2022-04-29 20:57:04 +03:00
David 'Epper' Marshall 881d0c04f1
time: add custom formatter (#14202) 2022-04-29 15:57:08 +03:00
yuyi ec865cfb37
parser: check interface methods name (fix #14217) (#14218) 2022-04-29 15:48:03 +03:00
yuyi 317acfda97
checker: check struct field name using uppercase letters (#14220) 2022-04-29 14:57:14 +03:00
Wertzui123 872f739396
builtin: ignore C++ 0xE06D7363 exception errors on windows (#14225) 2022-04-29 14:55:29 +03:00
StunxFS 995485c649
builtin: add `string.len_utf8()` method (#14208) 2022-04-29 10:23:57 +03:00
StunxFS 8b798acadd
cgen: fix use of C reserved words inside `defer` statement (fix #14101) (#14211) 2022-04-29 08:04:59 +03:00
Alexander Medvednikov 77645fcf35 builtin: define atoi & ftell 2022-04-29 04:31:51 +03:00
spaceface 14309594fe
ast: add a type_size() method (#14213) 2022-04-28 23:35:10 +03:00
David 'Epper' Marshall 5a42350a78
docs: add a `v fmt -w .` step in the contributing guide (#14210) 2022-04-28 23:31:22 +03:00
StunxFS e24482a143
transformer: minor optimization for `'string literal'.len` (#14207) 2022-04-28 22:35:16 +03:00
playX e56385d57d
checker: disable op overloading on structures for translated code (#14209) 2022-04-28 20:46:46 +03:00
yuyi 7aca67fb60
ast, parser: fix complex map init (#14206) 2022-04-28 17:37:19 +03:00
yuyi dd94ab890a
cgen: fix go anon fn call with ref argument (fix #14192) (#14197) 2022-04-28 14:43:20 +03:00
yuyi c802688690
ast: fix error for complex map operating (#14204) 2022-04-28 13:20:56 +03:00
Atom a225b25117
arrays: rephrase doc string (#14205) 2022-04-28 13:17:53 +03:00
Delyan Angelov 4538efd8f4
eval: small cleanup in the handling of `$if platform {` 2022-04-28 13:15:09 +03:00
Delyan Angelov e0ed8f8278
eval: make the interpreter backtrace more efficient and informative. 2022-04-28 12:31:30 +03:00
Delyan Angelov f72297c331
eval: add support for C.read/3, C.malloc/1, `$if openbsd {` 2022-04-28 11:30:36 +03:00
Delyan Angelov be04ec0620
pref: add support for `-thread-stack-size 4194304` (default set to 8MB) (#14168) 2022-04-28 08:46:33 +03:00
yuyi 7dd5d9ee61
checker: fix error for array of sumtype appending literal value (#14200) 2022-04-28 08:44:30 +03:00
yuyi 09f8b6a380
checker: check error in for_c_stmt with optional call (#14190) 2022-04-28 08:43:16 +03:00
tzSharing eb03fad934
gg: improve some loops in draw_rounded_rect* methods (#14195) 2022-04-27 22:57:48 +03:00
Delyan Angelov f53b9b4f12
ci: fix tcc compilation of atomic_test.v 2022-04-27 22:50:18 +03:00
Alexander Medvednikov 7dbfa86f25 all: atomic int fixes 2022-04-27 18:31:21 +03:00
yuyi 82ac39eca6
math: fix error for math.abs(0.0)/math.abs(0) (related #14165) (#14191) 2022-04-27 13:23:37 +03:00
yuyi 752e105f25
cgen: fix error for generic sumtype casting to typenode (#14188) 2022-04-27 11:32:43 +03:00
tzSharing 85f616877f
gg: fix gg.draw_rounded_rect_empty() graphical abnormalities and some optimizations (#14186) 2022-04-27 11:22:57 +03:00
playX b76095f28a
checker: allow + - * on pointers for translated code (#14183) 2022-04-26 21:00:44 +03:00
R cqls c26b7666c7
gg: some stuff required to have svg and png screenshots working on v ui (#14180) 2022-04-26 20:59:36 +03:00
yuyi be513b4c27
cgen: split up array_init() (#14178) 2022-04-26 20:58:47 +03:00
Larpon 1c48a8d760
strconv: add missing doc strings (#14164) 2022-04-26 18:09:36 +03:00
yuyi 660201c188
cgen: fix error for cast to empty interface (fix #14162) (#14176) 2022-04-26 13:26:48 +03:00
Brian Callahan b9a0e2d285
sokol: support compilation on OpenBSD (#14169) 2022-04-26 13:14:00 +03:00
yuyi 38afd74d26
ast, checker, cgen: fix error for multi-return in or expr (fix #14167) (#14172) 2022-04-26 12:17:05 +03:00
playX 95880dfe5c
checker: allow indexing through alias to int (#14177) 2022-04-26 12:15:35 +03:00
playX dce2173ac9
checker: c2v fixes (#14161) 2022-04-26 01:34:26 +03:00
Alexander Medvednikov 501b293e84 checker: remove already handled "undefined" errors 2022-04-25 16:53:34 +03:00
Larpon d799abd139
regex: rephrase doc string (#14159) 2022-04-25 16:03:13 +03:00
yuyi e42dc8e228
checker: fix error for match aliases (#14157) 2022-04-25 14:42:43 +03:00
yuyi f89c81087b
checker: check error for array.index() argument (#14147) 2022-04-25 14:42:31 +03:00
yuyi aeba110d01
cgen: fix error for printing multi fixed array (#14141) 2022-04-25 14:42:05 +03:00
Larpon 283d181047
cli: add missing doc strings (#14158) 2022-04-25 14:41:46 +03:00
yuyi 88f22b4367
cgen: fix error for anon fn decl inside ternary (#14150) 2022-04-25 12:36:03 +03:00
Delyan Angelov 60e205a193
tests: add ability to check the output of commands for .starts_with, .ends_with and .contains strings, in `v test-all` 2022-04-25 12:20:38 +03:00
Delyan Angelov d35d67c2bd
eval: enable `v interpret examples/hanoi.v` 2022-04-25 12:20:37 +03:00
Nick Treleaven d8a5df9044
checker: error if smaller signed == unsigned (#14078) 2022-04-25 12:09:25 +03:00
Delyan Angelov 147e6e669f
cgen: fix pushing to an array of string pointers (fix #14156) 2022-04-25 11:26:24 +03:00
yuyi 922cee9162
parser, checker, cgen: fix error for fn call using anon fn call argument (#14155) 2022-04-25 11:26:14 +03:00
Delyan Angelov 1291b621f6
ci: bump test retries for go_anon_fn_variable_call_test.v to 3 2022-04-25 10:32:41 +03:00
fleur ddbe812f1b
cgen: add callconv support for fns from ptr (#14151) 2022-04-25 08:51:03 +03:00
Haren S 11ee2b6409
builder: improve macOS 10.5 and PPC support (#14152) 2022-04-25 08:17:00 +03:00
stackotter 563469ed9f
vfmt: fix array_init line wrapping (#14154) 2022-04-25 08:11:44 +03:00
yuyi c819f0f86f
checker, cgen: fix printing in 'for v in a' (#14146) 2022-04-24 13:30:13 +03:00
Alexander Medvednikov 9355048b6c tmpl: minor fixes and optimizations 2022-04-23 16:01:44 +03:00
Delyan Angelov 3388caa6c5
ci: bump vtest retry to 6 for channel_select_test.v (fails sporadically in the windows-gcc job) 2022-04-23 15:36:19 +03:00
Delyan Angelov 365e7d6b34
vfmt: ignore parser warnings, cleanup code 2022-04-23 11:10:12 +03:00
yuyi d934472b17
checker: simplify checking array.contains() argument (#14133) 2022-04-22 22:34:13 +03:00
yuyi b86320a669
parser: minor cleanup in stmt() (#14136) 2022-04-22 22:33:13 +03:00
Claudio Cesar de Sá a2db44bc38
examples: add 2 more graph search examples (DFS and BFS), move them into `examples/graphs` (#14131) 2022-04-22 12:01:29 +03:00
yuyi 5dce091379
checker, cgen: fix generic empty interface to multi struct (#14132) 2022-04-22 11:02:51 +03:00
Alexander Medvednikov 9b565bf765 cgen: fix enum switch bug in translated code 2022-04-22 02:31:32 +03:00
tzSharing 03d21a727e
gg: fix gg.draw_rounded_rect_filled() graphical abnormalities (#14128) 2022-04-22 00:16:10 +03:00
Larpon 506259adb6
os: add behavior info to `is_dir_empty` documentation (#14110) 2022-04-21 18:21:00 +03:00
yuyi 26b0e7fd34
fmt: remove extra parentheses (#14125) 2022-04-21 18:20:32 +03:00
Delyan Angelov 2080557f50
ast: allow `a := match x { 101 { ... for {...} ... y }` 2022-04-21 13:31:06 +03:00
yuyi 8a18f9175a
cgen: fix error for if expr with nested match expr (#14122) 2022-04-21 13:02:31 +03:00
yuyi 448938be0d
parser: fix generic anon fn decl with type only argument (#14124) 2022-04-21 12:53:13 +03:00
yuyi 99eb9fdaab
checker: fix error for fn with array of aliases argument (#14123) 2022-04-21 12:52:09 +03:00
yuyi f13583b04a
checker: check array builtin method's arguments (#14119) 2022-04-21 12:51:04 +03:00
yuyi 8013bd43b0
checker: check map builtin method's arguments (#14120) 2022-04-21 12:49:46 +03:00
Delyan Angelov 5e8c4a3aff
ci: enable again the `v install ui` task 2022-04-21 11:21:59 +03:00
StunxFS 2a0b372d0d
tools: minor cleanup in fast.v (#14117) 2022-04-21 10:46:35 +03:00
ChAoS_UnItY c5824c36f2
checker, cgen: allow static (fixed) arrays in `in` operator (#14121) 2022-04-21 10:32:29 +03:00
Delyan Angelov c789ea5a15
ci: temporarily use `git clone https://github.com/vlang/xyz ~/.vmodules/xyz` instead of `v install xyz` 2022-04-21 09:20:15 +03:00
sunnylcw 4491b535ec
doc: add link to V's standard library documentation at the start (#14114) 2022-04-21 00:26:20 +03:00
Delyan Angelov 31b28af179
bootstrap: remove -I ./thirdparty/stdatomic/nix from make files (#14111) 2022-04-21 00:12:50 +03:00
lemon 960225f7a7
builtin: fix `-cc gcc -gc boehm` on linux and macos (#14115) 2022-04-21 00:12:17 +03:00
Nick Treleaven 1533b77404
builtin: remove unnecessary casts for defunct small unsigned warning (#14108) 2022-04-20 21:47:09 +03:00
yuyi 0260c2a552
checker: minor cleanup in assign_stmt() (#14107) 2022-04-20 21:03:41 +03:00
Hunam 0374f021c5
os: small cleanup of function description (#14112) 2022-04-20 20:58:41 +03:00
mjh 1546645f63
datatypes: fix bst child access, when .root is 0 (#14080) 2022-04-20 16:49:18 +03:00
Larpon a1342e85c3
os: add info about overwritten content to `write_file` (#14109) 2022-04-20 15:29:58 +03:00
yuyi 52ea0b8cc3
ast: minor cleanup of types.v (#14103) 2022-04-20 14:24:13 +03:00
yuyi ce4c2afc9c
checker, cgen: use 'stmts.last()' instead of 'stmts[stmts.len - 1]' (#14105) 2022-04-20 14:23:32 +03:00
yuyi 44ba19716b
checker: fix error for fn with multi return (#14095) 2022-04-20 13:09:40 +03:00
yuyi 0c3b69eaef
checker: fix error for assign array of aliases (#14096) 2022-04-20 13:08:47 +03:00
Alexander Medvednikov 364656b312 builtin: define C.abs() 2022-04-20 13:03:30 +03:00
Isaiah 0887b59254
vpm: fix get_all_modules() (#14097) 2022-04-20 12:15:30 +03:00
yuyi 8cc79e4299
checker: check error for arguments of array.contains() (#14102) 2022-04-20 11:00:59 +03:00
playX 711e90cf99
v.util: add math to builtin_module_names (temporary fix for C2V) (#14100) 2022-04-20 10:57:55 +03:00
playX f6a0c26a85
checker: c2v fixes (#14091) 2022-04-20 01:09:34 +03:00
Delyan Angelov 9646e4b9d8
sync: use #insert for atomic.h, so that bootstrapping can be simplified 2022-04-19 20:06:20 +03:00
Delyan Angelov 006df58451
checker, cgen: add support for #insert, to simplify bootstrapping V 2022-04-19 19:37:04 +03:00
JalonSolov daf5d32327
checker: fix error message when number of generic parameters is incorrect (#14090) 2022-04-19 18:34:23 +03:00
yuyi a318a2e09e
examples: fix optional in string interpolation and format error (#14079) 2022-04-19 13:29:53 +03:00
yuyi e16ce3af88
token: minor cleanup of token.v (#14083) 2022-04-19 13:28:27 +03:00
yuyi 6164654d11
checker: check fn return type mismatch (#14081) 2022-04-19 13:04:41 +03:00
Nick Treleaven 4400efeb9f
checker: Revert part of small_unsigned == signed (#13967) (#14075)
`gcc -W` doesn't error for e.g. u16 == i32, only for u32 == i16.
Any u16 value can fit in an i32.
2022-04-18 21:30:09 +03:00
yuyi 7ef64bde50
checker: check error for fn decl with optional arguments (#14076) 2022-04-18 21:22:31 +03:00
yuyi d0a11f50ca
cgen: minor cleanup of infix_expr.v (#14070) 2022-04-18 15:05:19 +03:00
Delyan Angelov 379b638b57
ci: update windows-install-sqlite.bat to latest sqlite 2022-04-18 14:25:57 +03:00
yuyi fe371845da
ast, checker, cgen: fix aggregations type check (#14066) 2022-04-18 12:38:08 +03:00
spaceface 775c4c34b5
builtin: compile the gc statically by default (#14063) 2022-04-18 10:50:21 +03:00
Ikko Ashimine 56a3539ea9
io: fix typo in readerwriter.v (#14060)
seperate -> separate
2022-04-17 17:40:14 +03:00
yuyi 17c34b09a6
checker, cgen: minor cleanup of last expr stmt expression (#14057) 2022-04-17 14:08:43 +03:00
yuyi cb44f5981e
checker, cgen: fix error for if expr with generic sumtype (#14056) 2022-04-17 08:19:44 +03:00
Vincenzo Palazzo 4f14f7714f
checker: ensure that the variant SubType exists (#14053)
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-04-16 19:29:10 +03:00
Vincenzo Palazzo 48486e1afb
ci: reformatted tools/vcreate.v (#14054)
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-04-16 19:09:08 +03:00
Cameron Katri 1fc54a1e5b
vcreate: Allow custom default license (#14046) 2022-04-16 17:43:25 +03:00
Delyan Angelov 8a57f7ed2d
v.util: always compile vfmt with `-d vfmt` to enable more efficient parsing 2022-04-16 14:05:55 +03:00
Julien de Carufel 16ead4e63c
cgen: fix infix generics bug (#14048) 2022-04-16 13:23:19 +03:00
Alexander Medvednikov 43931a8e77
doc: byte => u8 2022-04-16 13:02:56 +03:00
Delyan Angelov 5b7e538119
v.pref: show the VCROSS_COMPILER_NAME notice only when the output is not a .c file 2022-04-16 10:46:03 +03:00
Delyan Angelov 4a71b27c52
ci: add test_byte_vs_u8 to int_test.v 2022-04-15 21:42:07 +03:00
Delyan Angelov d75c408868
ci: fix typeof_simple_types_test.v 2022-04-15 21:22:32 +03:00
Delyan Angelov 82c5621621
ci: fix typeof_simple_types_test.v 2022-04-15 21:21:44 +03:00
Delyan Angelov 675f8b6300
ci: fix generic_fn_infer_struct_test.v 2022-04-15 21:21:12 +03:00
Delyan Angelov ad231cec2f
ci: fix code_test.v 2022-04-15 21:20:03 +03:00
Delyan Angelov 87a373d82c
ci: fix coutput_test.v 2022-04-15 21:18:55 +03:00
Delyan Angelov c7aedb8e8d
ci: fix fmt_test.v 2022-04-15 21:16:31 +03:00
Delyan Angelov 375361b787
ci: fix `./v check-md -hide-warnings .` 2022-04-15 21:08:09 +03:00
Delyan Angelov 840f474fb5
ci: fix `./v -progress test-cleancode` 2022-04-15 21:04:10 +03:00
Delyan Angelov e802e0b9cb
ci: fix more test-all failures 2022-04-15 21:02:03 +03:00
Delyan Angelov bb2a324d61
ci: more gen.js fixes 2022-04-15 20:51:04 +03:00
Delyan Angelov 868d3e1008
ci: fix failing tests for mysql, crypto.rc4, strings 2022-04-15 20:51:04 +03:00
Alexander Medvednikov c03fe020bf parser: do not allow [x]byte{} 2022-04-15 20:40:37 +03:00
Delyan Angelov 6f5a513d8b
ci: fix `v build-examples` 2022-04-15 20:31:10 +03:00
Delyan Angelov e18cb9748f
ci: fix `v check-md doc/docs.md` 2022-04-15 20:25:19 +03:00
Delyan Angelov 173e6a943b
checker: fix tests (adjust byte to u8 in .out files too) 2022-04-15 20:15:03 +03:00
Delyan Angelov cc8803c602
builtin: fix failing embed_file_test.v (`pub fn (data &u8) vbytes(len int) []u8 {`) 2022-04-15 19:57:00 +03:00
Alexander Medvednikov 78cb6e2b41 all: handle fixed []u8 2022-04-15 18:35:56 +03:00
Alexander Medvednikov 1c6f63ac0a tests: use u8 everywhere 2022-04-15 18:34:15 +03:00
Alexander Medvednikov fbb9e65c0f all: ~500 more byte=>u8 2022-04-15 18:25:45 +03:00
Alexander Medvednikov ae6a25f44e websocket, utf: u8 fixes 2022-04-15 16:24:02 +03:00
Alexander Medvednikov e97ebf8cfc sokol: byte => u8 2022-04-15 16:12:05 +03:00
Alexander Medvednikov 258d1f77dc net: fix byte buffers 2022-04-15 15:57:45 +03:00
Alexander Medvednikov af73e195da net: byte fixes 2022-04-15 15:55:39 +03:00
Alexander Medvednikov fb192d949b all: replace []byte with []u8 2022-04-15 15:35:35 +03:00
Alexander Medvednikov 0527ac633e ast: remove .byte 2022-04-15 15:30:37 +03:00
Alexander Medvednikov dbcf6e9c33 os: fix Process on windows 2022-04-15 15:23:05 +03:00
Alexander Medvednikov c14984899b builtin: fix windows fn definitions 2022-04-15 15:18:21 +03:00
Alexander Medvednikov a1372e284c builtin: update alloc fn definitions 2022-04-15 15:16:10 +03:00
Alexander Medvednikov c3ad4e2069 encoding.base64: use u8 2022-04-15 15:10:34 +03:00
Alexander Medvednikov d4a0d6f73c all: byte => u8 2022-04-15 14:58:56 +03:00
Alexander Medvednikov b49d873217 builtin: [1000]u8 fix 2022-04-15 14:48:39 +03:00
Alexander Medvednikov 014c3c97f0 all: byte => u8 2022-04-15 14:45:52 +03:00
Alexander Medvednikov 7f3b91e688 builtin: more byte => u8 2022-04-15 14:10:11 +03:00
Alexander Medvednikov 1e7eb713fb cgen: remove byte references from cheaders.v 2022-04-15 14:04:53 +03:00
Alexander Medvednikov ba7b329c73 builtin: more byte=>u8 2022-04-15 13:55:56 +03:00
Alexander Medvednikov e6ff1508d2 all: make u8 the primary type, byte the alias 2022-04-15 13:43:03 +03:00
Delyan Angelov 566f150b24
net.http: add parse_request_head/1, cleanup existing code 2022-04-15 10:33:44 +03:00
Delyan Angelov c3ee4fb2a2
crypto: make public all Digest.checksum() methods 2022-04-15 09:02:42 +03:00
Alexander Medvednikov 3b36f16365 all: volatile globals 2022-04-15 02:39:38 +03:00
Alexander Medvednikov 0dff050735 builtin: u8/byte clean up 2022-04-14 16:43:34 +03:00
yuyi 2d6d6c9ac9
json: fix json decode with sumtype of multi array type (#14035) 2022-04-14 15:36:24 +03:00
yuyi c4dff0d797
cgen: format the generated source code by gen_str_for_union_sum_type() (#14026) 2022-04-14 15:26:10 +03:00
yuyi 72c2dc805d
cgen: fix error for generics struct that parent has str to string (#14037) 2022-04-14 15:23:50 +03:00
Delyan Angelov f6c9a60f99
pref: only show the support cross compiler warning/VCROSS_COMPILER_NAME message for the C backend 2022-04-14 15:04:00 +03:00
Delyan Angelov bf62b2e33e
vfmt: stabilise the attribute sorting order (sort first by length of atributes, then in alphabetical order of their names) 2022-04-14 14:53:45 +03:00
Delyan Angelov f1f75897b3
sync: use asserts in channel code only when `-d debug` is passed 2022-04-14 14:00:57 +03:00
Delyan Angelov a62560d2c1
ci: fix generation of vc/v_win.c in gen_vc.yml 2022-04-14 13:44:18 +03:00
Delyan Angelov e555335bf0
ci: fix windows-msvc builds, as well as the windows-cross job, turn on deprecation notices for [windows_stdcall] and [_fastcall] 2022-04-14 13:36:51 +03:00
fleur 68401d9dc8
gen: add callconv attribute for fn and type (#14027) 2022-04-14 11:29:52 +03:00
Delyan Angelov 5905590e78
builder, pref: use i686-w64-mingw32-gcc for cross compiling 32bit windows apps with `v -m32 -os windows hw.v` 2022-04-14 10:42:25 +03:00
Vincenzo Palazzo 48c295150f
checker: fixes typechecking for a sum type with an alias type (#13974) 2022-04-13 18:38:26 +03:00
yuyi dc08105022
json: fix error for json decode with sumtype (#14025) 2022-04-13 18:06:28 +03:00
Delyan Angelov e5809363de
docs: describe the contents of vlib/v/gen/c/testdata/ and how to write tests for the checker, that still do not have good codegen counterpart 2022-04-13 14:55:26 +03:00
Alexander Medvednikov d7adb67d52 cgen: fix [cinit] 2022-04-13 02:55:47 +03:00
Alexander Medvednikov 2525a30b5f cgen: [cinit] attr for globals 2022-04-13 00:30:51 +03:00
yuyi e3e5bef139
ast, parser: fix formatting of `if` with inline comments (fix #7796) (#14018) 2022-04-13 00:15:27 +03:00
Nick Treleaven c780de6282
checker: disallow 'small_unsigned == signed' (#13967) 2022-04-12 19:37:30 +03:00
fleur 6718958058
cgen: add a `[_fastcall]` fn attribute (#14016) 2022-04-12 17:06:56 +03:00
牧心 a810fbb80e
cgen: fix infix_expr_in_optimization compile error when treating some kind cannot directly use '==' (#14015) 2022-04-12 16:19:44 +03:00
Delyan Angelov 8788512c4d
checker: make using err.msg and err.code produce an *actual* notice, even with the present compatibility hack (will be *removed* in 2022-06-01) 2022-04-12 14:56:02 +03:00
Delyan Angelov 4c7cdd2a2d
checker,cgen: use faster `sym.idx == ast.error_type_idx` integer comparisons, instead of `sym.name == "IError"` 2022-04-12 14:49:51 +03:00
Delyan Angelov 62032c43db
ast: fix Table.rewrite_already_registered_symbol calls (they were setting sym.idx to 0) 2022-04-12 14:49:51 +03:00
Delyan Angelov 9b43713ec5
net: simplify TcpListener.accept, use `C.accept(l.sock.handle, 0, 0)`, since we do not care about the local address of the accepted connection 2022-04-12 11:47:41 +03:00
Delyan Angelov 716cb17aea
math.big: wrap all asserts in module code (not in tests) in `$if debug {}` (#14012) 2022-04-12 09:38:53 +03:00
crthpl afb07e0e16
cgen: fix deadlock when returning multiple values in lock (#14014) 2022-04-12 09:21:27 +03:00
yuyi 3e3b2e25db
parser, fmt: fix the formatting of fn headers with inline comments (#14010) 2022-04-11 22:31:06 +03:00
Larpon 07207db998
examples: reduce C. prefix usage, rename fontstash enums (#14011) 2022-04-11 22:23:06 +03:00
Delyan Angelov cb969e0934
tools: fix the behaviour of regress.v , when oldv.v is not compiled 2022-04-11 21:57:33 +03:00
Delyan Angelov 382586da6d
ci: fix toml segfault (remove unused low level builtin option IError.msg compatibility hack) 2022-04-11 21:49:59 +03:00
Delyan Angelov e64c8cce62
ci: bump size of EMPTY_STRUCT_DECLARATION's _dummy_pad field to 8 (a voidptr, instead of char) 2022-04-11 17:53:18 +03:00
yuyi 5551cb248c
ast, parser, fmt: fix formatting of consts with embedded comments (#14008) 2022-04-11 17:27:41 +03:00
牧心 25d8faabf6
cgen: fix alloc empty struct array error (#14007) 2022-04-11 14:16:09 +03:00
Delyan Angelov 843ce43077
strconv: cleanup atof.c.v - use a ParserState enum, clarify comments 2022-04-11 12:01:47 +03:00
Delyan Angelov e4dfffd70b
toml: remove math import (used only for math.max and math.max_u32) 2022-04-11 10:22:31 +03:00
Nick Treleaven 1938bc48e7
toml.scanner: make end_of_text, at, next and peek return u32 (#13998) 2022-04-11 10:12:04 +03:00
yuyi fa66183f43
checker: check error for map of generic struct init (#13999) 2022-04-11 10:07:23 +03:00
Delyan Angelov a0e7a46be4 rand: speed up MT19937RNG.u64 2022-04-10 13:07:35 +03:00
Delyan Angelov 6c25f5b291 rand: fix needless array allocation in MT19937RNG.u64() 2022-04-10 13:02:31 +03:00
Subhomoy Haldar 3f90809035
rand: add missing pub modifiers for .byte() and .u32() methods (#13992) 2022-04-10 11:43:46 +03:00
牧心 11d9a67e3b
cgen: fix invalid operands to `an_alias in an_array_of_aliased_values` (#13994) 2022-04-10 11:42:17 +03:00
Delyan Angelov 8517b8f8b0
examples: use #[] in news_fetcher.v to simplify the code 2022-04-10 11:11:53 +03:00
Delyan Angelov 88c4a64a15
examples: make examples/sokol/drawing.v more symmetrical 2022-04-10 10:40:14 +03:00
yuyi 93a5d03182
parser: improve embedded struct parsing/better error for `Architecture []string` (#13995) 2022-04-10 10:24:36 +03:00
Vincenzo Palazzo 3571f66a82
pref: fix access in invalid position on `v search ''` (#13993) 2022-04-10 10:21:58 +03:00
yuyi 473bc0254d
checker: check error for array of generic struct init (#13987) 2022-04-09 21:50:34 +03:00
Delyan Angelov 89d64b21ea
ci: remove manual free(f) in an autofree test, after 58febe46, which does it automatically now 2022-04-09 20:06:27 +03:00
Delyan Angelov df30b79971
checker: allow for `arr.any(opt_fn()?)`, add test 2022-04-09 19:50:10 +03:00
Daniel Oberhoff 58febe4607
cgen: fix autofree of heap variables (#13823) 2022-04-09 17:37:39 +03:00
yuyi 704e3c6e72
cgen: fix error for fn with fixed array argument (fix #13976) (#13982) 2022-04-09 15:57:27 +03:00
Nick Treleaven bf385d2ac9
docs: add links to download C compilers (#13984) 2022-04-09 15:53:37 +03:00
pancake 804f2f56d4
vpm: support `v install -once module_name`(#13977) 2022-04-09 14:29:41 +03:00
pancake e3da3101f6
vpm: simplify output for `v list` (#13975) 2022-04-09 14:26:01 +03:00
Delyan Angelov 60e718e7c6 test: save removing the nonexistent binary output for v fmt and v vet tests 2022-04-09 13:04:52 +03:00
Vincenzo Palazzo 2d867a2766
ast: fix reported errors, when arrays of types defined in modules are involved (#13952) 2022-04-08 17:38:34 +03:00
yuyi 2a88b313d4
cgen: format json encode/decode generated c codes (#13972) 2022-04-08 17:27:05 +03:00
yuyi 617608b23d
cgen: fix optional struct declarations for empty structs (#13970) 2022-04-08 14:51:37 +03:00
Larpon 45a427e68b
clipboard: fix segfault when pasting to some X11 apps. Fixes #13891 (#13971) 2022-04-08 13:32:38 +03:00
Larpon 52f1c615a6
fontstash: document all functions (#13969) 2022-04-08 13:22:23 +03:00
Joe Conigliaro a0c07454b1
checker: remove debug code from previous commit 2022-04-08 18:27:14 +10:00
Joe Conigliaro 426e9d1734
checker: fix condition for checking if tmpl var is inherited 2022-04-08 18:25:08 +10:00
Joe Conigliaro e1c8b07fa5
checker/tests: format test added in prev commit & rename chekcer prop 2022-04-08 17:41:23 +10:00
Joe Conigliaro 8dc2601080
all: comptime_call - simplify tmpl scoping, solves many issues. 2022-04-08 17:33:24 +10:00
mir.zhou 6425000ce4
example: fix the tuicool.com crawler example (changed html structure) (#13962) 2022-04-07 18:18:10 +03:00
Delyan Angelov 5a695c81dc
ci: fix the recorded output for compare_structs.c.must_have after eea46c4 2022-04-07 18:08:56 +03:00
crthpl b232a3b0d1
cgen: fix `.filter()` and `.map()` on shared arrays (#13954) 2022-04-07 18:05:11 +03:00
Delyan Angelov eea46c4e1a
cgen: fix error, when a struct with over 8 fields, is used as a method receiver directly. 2022-04-07 17:20:14 +03:00
Subhomoy Haldar 022fae1e7f
rand: make mt19937 automatically seeded, add seed_len to wyrand (#13966) 2022-04-07 16:00:30 +03:00
Pascal Masschelier 95753ffb30
examples: fix process_stdin_trick example (#13953) 2022-04-07 13:55:12 +03:00
playX 6a820c2845
checker: allow all binary operations when translating code produced by c2v (#13964) 2022-04-07 12:22:24 +03:00
Vincenzo Palazzo 4666a27e5f
ci: introduce v benchmarks inside the ci workflow (#13949) 2022-04-07 12:21:13 +03:00
Larpon d34ef69229
tools: improve deprecation detection in missdoc.v (#13960) 2022-04-07 12:20:14 +03:00
yuyi e7fd8c4e7c
cgen: fix error for dereference mut interface in loop (fix #13913) (#13941) 2022-04-07 12:01:54 +03:00
yuyi a58dde48f8
cgen: fix error for optional multi return (#13959) 2022-04-07 09:12:23 +03:00
yuyi c9dcdf6744
cgen: fix json decode with optional argument (fix #13943) (#13958) 2022-04-06 19:34:22 +03:00
Larpon 56e6fd01c5
gg: document pub functions in text_rendering and m4/vector (#13961) 2022-04-06 19:34:02 +03:00
Delyan Angelov c5d8d27b90 ci: fix -cstrict failures for vweb_test.v etc. 2022-04-06 08:54:01 +03:00
Vincenzo Palazzo 6412f8ba0b
checker: add a known error on alias cast with generics (#13946) 2022-04-05 19:09:46 +03:00
Larpon 1482db6d1a
gg: add missing doc strings to android, recorder and gg.c.v (#13936) 2022-04-05 18:42:01 +03:00
Vincenzo Palazzo 359f16fdfd
parser: fixed parsing prototype function with recursive type (#13922) 2022-04-05 18:39:49 +03:00
yuyi 0cba579a7b
cgen: simplify codegen for optional consts (#13948) 2022-04-05 17:54:23 +03:00
Delyan Angelov 2ecfd1b351
ci: fix clang sanitize errors for json_decode 2022-04-05 17:52:10 +03:00
Larpon 11ccf06441
time: add missing doc string to parse.v (#13933) 2022-04-05 13:21:37 +03:00
Larpon 2350dbbd57
gg: add missing doc strings to pub fns in image.* (#13934) 2022-04-05 13:21:03 +03:00
Larpon 0b046c14a8
clipboard: add doc strings to all implementations (#13932) 2022-04-05 13:06:32 +03:00
Delyan Angelov f5e4d17cf3
json: return errors with more context, on failed json.decode() calls. 2022-04-05 12:06:08 +03:00
Alexander Medvednikov 829fed4af0 ci: build vpm again 2022-04-05 08:02:47 +03:00
Nick Treleaven 7d8db1042d
vdoc: don't highlight less than expression as generic function (#13938) 2022-04-05 05:58:47 +03:00
yuyi f6b8e1e13f
cgen: fix error for const using nested optionals (#13939) 2022-04-05 05:58:11 +03:00
Delyan Angelov 0bd8fbc9a8 term, term.ui: fix a panic on !=linux unixes when running examples/term.ui/ 2022-04-04 19:25:25 +03:00
Nick Treleaven 2cd9c91e98
vdoc: highlight terminal examples for `-comments -color` (#13937) 2022-04-04 18:13:24 +03:00
Larpon aa9e2ebb25
gg: document all draw functions (#13931) 2022-04-04 18:09:19 +03:00
pancake 5369379738
repl: handle exit(n) (#13930) 2022-04-04 16:22:34 +03:00
Alexander Medvednikov 92bfd9b353 cgen: fixed array index for translated code 2022-04-04 12:09:29 +03:00
StunxFS 725b472d37
checker: fix typos (#13929) 2022-04-04 10:07:53 +03:00
Nick Treleaven 91b40304b7
vdoc: highlight `..`, `...` as punctuation & postfix ops as operators (#13924) 2022-04-04 09:21:54 +03:00
StunxFS 1211b2e941
v: minor change in the output for an unknown help topic (#13927) 2022-04-04 08:36:10 +03:00
Alexander Medvednikov 719a3b5de3 cgen: fix fixed arrays assignment in translated code 2022-04-04 06:20:54 +03:00
Alexander Medvednikov a55e930c00 checker: fix pointer checks in translated code 2022-04-04 05:35:15 +03:00
Alexander Medvednikov cc227d8520 checker: fix non-numeric type check for translated code 2022-04-04 04:59:14 +03:00
Nick Treleaven d10135e2c4
vdoc: HTML highlight generic function as function, not name (#13923) 2022-04-03 23:41:02 +03:00
Delyan Angelov 44603f8e59
checker: add suggestions for misspelled `mod.func_name()` calls 2022-04-03 20:07:52 +03:00
Vincenzo Palazzo 51c1d666c2
checker: fix operator overloads (for large structs with > 8 fields, the method receiver is normally auto converted to a reference) (#13889) 2022-04-03 19:30:29 +03:00
StunxFS 38853568b4
encoding.csv: allow passing a custom delimiter to the `new_reader` function (#13910) 2022-04-03 19:13:43 +03:00
Nick Treleaven 782d5374c9
builtin: add an `array.drop(n)` method (#13907) 2022-04-03 17:05:50 +03:00
Delyan Angelov a1e9cae5d2
tests: add a vlib/v/tests/known_errors/known_errors_test.v test runner 2022-04-03 12:54:22 +03:00
yuyi 0497b885dc
checker: minor cleanup in find_unreachable_statements_after_noreturn_calls() (#13903) 2022-04-03 11:19:19 +03:00
yuyi 8c55a9ecd3
builtin: minor optimization of array.push() and array.push_noscan() (#13904) 2022-04-03 11:04:18 +03:00
Cameron Katri 340543dfc0
cli: add automatic manpage generation with -man (#13911) 2022-04-03 10:12:47 +03:00
Delyan Angelov 71dc6c224a
tests: make vlib/net/udp_test.v more stable, and less noisy on the tests-sanitize-address-gcc job 2022-04-02 20:00:26 +03:00
Cameron Katri d585fbea8a
time: implement Time.strftime(fmt string) as a wrapper for strftime(3) (#13898) 2022-04-02 18:33:37 +03:00
Nick Treleaven 42f92db0ab
v.doc: parse multi-line examples (so they get highlighted) (#13894) 2022-04-02 18:29:12 +03:00
yuyi faa55b46de
cgen: fix array of fixed array (fix #13895) (#13901) 2022-04-02 18:00:59 +03:00
yuyi 0bf0c73a49
checker: fix error for returning optional (#13902) 2022-04-02 17:25:01 +03:00
pancake af79c1e6ef
os: implement os.config_dir() like in Go's UserConfigDir (#13893) 2022-04-01 22:04:43 +03:00
Vincenzo Palazzo d7817863c6
checker: type inference over a generic type should compile (#13824) 2022-04-01 19:31:27 +03:00
Delyan Angelov 9d2529b611
ci: reduce repetitions in test_global_mutex in init_global_test.v
With the old number of repetitions (2500000), that test alone could take over
30 seconds, in the CI environment.
2022-04-01 19:23:15 +03:00
yuyi 6987f2c087
time: fix error for time.local() on windows (#13892) 2022-04-01 17:16:46 +03:00
Vincenzo Palazzo 02c80bd445
time: fix repetitive time.now().local().local().local() offsetting the time further and further (#13861) 2022-04-01 00:11:17 +03:00
Nick Treleaven 9c1981a309
vdoc: show `//` comment prefix and hide any \x01 character (#13880) 2022-03-31 20:00:06 +03:00
yuyi bc98c11d9d
parser, checker, cgen: minor cleanup of go_expr() (#13875) 2022-03-31 19:58:04 +03:00
yuyi db3bbb58cf
cgen: fix error for cross assign of the reserved name variable (#13884) 2022-03-31 19:55:21 +03:00
Nick Treleaven a87cd9663e
vdoc: highlight inline examples for `-f html` (#13879) 2022-03-31 19:32:32 +03:00
R cqls 5c43493183
sokol: add support for compiling with `-d darwin_sokol_glcore33` on macos (#13885) 2022-03-31 16:52:21 +03:00
Delyan Angelov fb5df9665e
ci: use ./v instead of v in "Shader examples could be build" step 2022-03-31 13:53:02 +03:00
Delyan Angelov fa3fa2e74f
ci: add again `sudo apt-get update` for the `Install dependencies` step 2022-03-31 13:44:42 +03:00
Cameron Katri b15240185e
builder,cgen: iOS fixes (#13883) 2022-03-31 11:51:13 +03:00
Delyan Angelov 4222fd0862
ci: add vlang/pdf testing task, simplify other_ci.yml using `v should-compile-all` 2022-03-31 11:35:20 +03:00
Delyan Angelov 74eabba52e
tools: add a `v should-compile-all examples/*.v examples/gg/` tool, to simplify CIs of V modules. 2022-03-31 11:13:20 +03:00
kylepritchard 6137ce23c0
math: allow `acos(0)` (fix #13876) (#13877) 2022-03-30 21:36:50 +03:00
yuyi ae1cb5697e
cgen: minor cleanup in ref_or_deref_arg() (#13874) 2022-03-30 21:06:38 +03:00
yuyi d40a502981
checker: minor cleanup in fn_call() (#13873) 2022-03-30 21:05:17 +03:00
Delyan Angelov 61f078664c
ci: entirely delete the `Code CI / arm64-ubuntu-tcc` Cirrus job, since it does not honor `trigger_type: manual`, but simply timeouts after severah hours, showing fake positives in the github CI 2022-03-30 16:00:01 +03:00
Subhomoy Haldar 7ef7188f4b
math.big: add bit_len, optimize gcd, add documentation (#13872) 2022-03-30 15:52:09 +03:00
Delyan Angelov 8121a8ada0 ci,cgen: comment out including stdbool.h for now
Fails tcc tests on windows, see: https://github.com/vlang/v/runs/5749951315?check_suite_focus=true
and vlib/v/checker/tests/globals_run/function_stored_in_global.vv
2022-03-30 14:26:20 +03:00
Delyan Angelov 566735b298 cgen: add `nil` to c_reserved (it is a macro defined in MacTypes.h on macos) 2022-03-30 13:33:03 +03:00
Cameron Katri 093994655c
v.builder: fix iOS compilation from non-macOS, allow -cc to override the default cross compiler (#13866) 2022-03-30 10:26:13 +03:00
Cameron Katri 3e69d3813b
v.builder: fix linker flags for systems with Procursus (#13865) 2022-03-30 10:15:52 +03:00
Delyan Angelov cc637e5ee8
checker: make the misssing shared/mut modifer in fn and method calls error clearer 2022-03-30 01:45:40 +03:00
yuyi 55d9464890
checker: fix error for marking as referenced (#13859) 2022-03-30 01:33:10 +03:00
yuyi 42a67831bf
parser: fix printing slice of multiline raw string (#13856) 2022-03-29 18:06:11 +03:00
yuyi c71770d9c5
checker: fix error for array of anon fn call (#13858) 2022-03-29 18:04:30 +03:00
Delyan Angelov 04cc037955
ci: fix -cstrict compilation of term.ui tests 2022-03-29 18:03:05 +03:00
Delyan Angelov 7ee93c8a20
docs: show the full information for deprecated functions 2022-03-29 15:17:55 +03:00
yuyi fd34ebd84e
checker: check the count of generics in fn arguments (#13855) 2022-03-29 10:04:19 +03:00
Delyan Angelov 4f551d76c0 term.ui: fix conflicting C struct declarations when compiling programs, importing term.ui before term, on windows 2022-03-29 09:31:24 +03:00
yuyi 509367b293
cgen: minor cleanup in expr_is_multi_return_call() (#13846) 2022-03-28 20:38:23 +03:00
Nick Treleaven 476f19c090
vdoc: tweak keyword, attribute and light theme CSS (#13853)
Make keywords bold.
Make attributes use a monospace font (like code).
Tweak light theme foreground colors:
* Make default-text, operator-text and punctuation-text a bit darker,
  improving the contrast.
* Make builtin-text a bit darker and more green (similar to dark theme).
* Make function-text a bit darker and more greeny-blue (similar to dark
  theme).
* Make attribute-text a bit less transparent for better contrast.
2022-03-28 20:38:00 +03:00
yuyi dd1a8cbadc
parser: check error for struct field type using 'mut' (#13847) 2022-03-28 18:13:38 +03:00
yuyi 62553dcc2e
cgen: fix crash for casting bool to int (fix #13825) (#13844) 2022-03-28 12:20:47 +03:00
Nick Treleaven c7a92425f0
doc: tweak built-in functions section & move `dump` section here (#13841) 2022-03-27 18:05:44 +03:00
Nick Treleaven afdf8f50e7
doc: move enum methods to enum section from sum types (#13843) 2022-03-27 17:46:20 +03:00
Nick Treleaven 3a4bb09de2
doc: improve Arrays section (#13842) 2022-03-27 17:45:00 +03:00
Subhomoy Haldar f75ce9dd82
rand: move functions from rand.util to the main module (#13840) 2022-03-27 17:38:59 +03:00
yuyi 875ad1f6ea
ast: minor cleanup in ast.v (#13839) 2022-03-27 16:21:40 +03:00
Nick Treleaven d748529337
doc: add links to notable array related subheadings (#13838) 2022-03-27 14:29:20 +03:00
Nick Treleaven 02f72c8230
builtin: improve docs for array methods that take an `it` expression, like .map, .filter etc (#13836)
Move explanation about boolean `it` expressions to `filter`, as `sort`
doesn't take a boolean expression. Also move `any` example.
Add 2 filter examples.
Add map example from docs.md.
2022-03-27 14:28:15 +03:00
Nick Treleaven dc9fd2bd7e
doc: tweak array methods section (#13837) 2022-03-27 14:26:23 +03:00
Delyan Angelov a07d066e8f
tools: cleanup all temporary files on successfull `v check-md .` 2022-03-27 10:24:10 +03:00
Delyan Angelov 0e496a8de2
tests: add an autofree regression test before return value ownership changes 2022-03-27 09:50:37 +03:00
Delyan Angelov bea0d500d0
parser: ignore upper letter case restriction for `fn C.xyz` declarations 2022-03-26 21:20:28 +02:00
Nick Treleaven fcb57312b9
parser: error if parameter name starts with a capital (#13827) 2022-03-26 19:56:34 +02:00
Delyan Angelov 8c396356bb
context: make the examples in the vlib/context/README.md immediately runnable 2022-03-26 13:25:45 +02:00
Delyan Angelov 7f28d91190 ci: fix again -usecache regression on macos 2022-03-26 09:47:44 +02:00
Alexander Medvednikov 0248349e7c cgen: global/const fixes 2022-03-25 23:33:01 +03:00
Nick Treleaven ea4410cdb5
builtin: document the rune.length_in_bytes method (#13826) 2022-03-25 20:09:39 +02:00
Delyan Angelov 347db755c8
tests: sort the test files before further processing in valgrind_test.v 2022-03-25 09:41:45 +02:00
Delyan Angelov ddc2c49365
cgen: autofree out of scope variables in reverse order of their creation 2022-03-25 09:39:12 +02:00
Delyan Angelov d6c40865f9
strings: cleanup unsafe casts in some of strings.Builder ops (#13819) 2022-03-25 00:07:15 +02:00
Delyan Angelov 5b492e26dd
builtin: support a.flags.set(.noslices | .noshrink), use it in the particles example (#13818) 2022-03-24 23:37:13 +02:00
Nick Treleaven a4ab3c1f14
checker: disallow `mut_ptr = &immutable_var` (#13814) 2022-03-24 20:43:25 +02:00
Delyan Angelov 9bbb52e9cc
checker: add a check for `dump(c)`, where `typeof(c) == "char"` 2022-03-24 12:11:59 +02:00
yuyi 78d9975798
ast, cgen: restore Type.str() and fix error for it (#13815) 2022-03-24 11:45:06 +02:00
yuyi 1566f7f766
checker: minor cleanup in check_types.v (#13816) 2022-03-24 08:59:05 +02:00
Delyan Angelov 5b668dba2b
sync: document sync.thread_id() 2022-03-23 19:52:20 +02:00
Delyan Angelov ce576d01c4
sync: add `sync.thread_id() u64 {` (#13810) 2022-03-23 19:19:14 +03:00
Nick Treleaven 2e963e36ac
rand: add `pub fn shuffle<T>(mut a []T) {` function + tests (#13811) 2022-03-23 15:31:26 +02:00
yuyi 35cd8112a5
ast, checker, cgen: fix error for printing alias that has str method (#13809) 2022-03-23 11:52:48 +02:00
Vincenzo Palazzo 8b072aa962
checker: check if generic values have the same types (#13718) 2022-03-23 09:13:10 +02:00
yuyi dff39bac78
cgen: fix error for defining global anonymous functions (#13808) 2022-03-23 08:09:15 +02:00
yuyi e3dca82f9c
strconv: minor cleanup in f64_to_str_lnd1() (#13804) 2022-03-22 20:15:59 +02:00
yuyi 0337882240
checker: check redefine global 'main' function (#13803) 2022-03-22 17:39:12 +02:00
Larpon 894080b844
ci: update sdl ci to compile shader example (#13805) 2022-03-22 17:36:23 +02:00
Ikko Ashimine 82120d02a8
tools: fix typo in vbug.v (#13802) 2022-03-22 15:47:03 +02:00
yuyi a9837ba95d
cgen: minor cleanup in go_expr() (#13801) 2022-03-22 12:07:46 +02:00
yuyi 56f5ed4789
strconv: fix error for string interpolation of float format (#13800) 2022-03-22 12:00:18 +02:00
Nick Treleaven afbccf79f7
builtin: don't memdup element for `array.pop` (depends on how cgen works) (#13789)
The voidptr returned is immediately dereferenced in cgen so the memory
is copied before the array can be appended to: `*(int*)array_pop(&a)`
2022-03-21 23:34:35 +02:00
yuyi f66d2f5d43
cgen: simplify in index_of_array() and add test (#13792) 2022-03-21 22:03:45 +02:00
Delyan Angelov 381cf4b61d
ci: bump retries to 3, for flaky vlib/v/tests/go_array_wait_test.v 2022-03-21 21:47:01 +02:00
yuyi c0437afbcd
cgen: fix error for casting int to interface (#13790) 2022-03-21 21:18:11 +02:00
Delyan Angelov 9ad64b0bd8
vweb: support `-d trace_request` and `-d trace_response` 2022-03-21 19:48:47 +02:00
Delyan Angelov 178afd006b
examples: avoid flash of unstyled content in the vweb_assets example 2022-03-21 19:13:53 +02:00
Delyan Angelov 3bae489e35
examples: make the vweb_assets.v example more robust (always change work folder to the folder of the executable). Document the vweb.Context.handle_static behaviour. 2022-03-21 19:05:18 +02:00
Delyan Angelov f2e0ab5912
docs: add formatting example for `"[${10.0000:.2f}]"` 2022-03-21 14:42:18 +02:00
yuyi 5815ab8d00
cgen: minor cleanup in index.v (#13788) 2022-03-21 13:10:10 +02:00
yuyi 81bb1ea71f
tests: cleanup go_anon_fn_variable_call_test.v (#13786) 2022-03-21 13:04:43 +02:00
El Koulali András f5036629ca
cgen: add `true` and `false` to C reserved words (#13781) 2022-03-21 11:00:30 +02:00
yuyi d9cca53bd0
checker: check error for index of optional (#13785) 2022-03-21 10:17:57 +02:00
Delyan Angelov 21e9b1deb0 ci: fix -usecache failure on macos 2022-03-21 08:52:25 +02:00
Alexander Medvednikov 80c94ea73e cgen: fix c2v consts in .o files 2022-03-21 04:56:37 +03:00
yuyi c4b424717c
cgen: fix error for map get anon fn value (#13782) 2022-03-21 00:20:55 +02:00
Delyan Angelov aaf87e04a2
tools: make the mini greeting text in the REPL more informative 2022-03-20 23:22:46 +02:00
Delyan Angelov 7216b5df11
tools: force showing V errors in color in interactive REPLs 2022-03-20 23:04:20 +02:00
Delyan Angelov caa0e25939
cgen: fix struct type dependency sorting, when struct field types, are aliases to struct types from other modules (#13779) 2022-03-20 20:23:48 +02:00
Delyan Angelov 71edaa071a
builtin: use malloc, instead of calloc in array.ensure_cap/1 2022-03-20 15:08:42 +02:00
yuyi 0a78847782
checker: check error for unknown type in anon fn field of struct (#13778) 2022-03-20 13:28:35 +02:00
yuyi 8c3687aa10
checker: check error for struct field init with nobody anon fn (#13777) 2022-03-20 13:04:31 +02:00
Delyan Angelov 8ab0bcb6aa
Revert "builtin: improve performance for common array ops, based on VTune analysis"
This reverts commit 57db261538.
2022-03-20 12:57:27 +02:00
Delyan Angelov 57db261538
builtin: improve performance for common array ops, based on VTune analysis 2022-03-20 12:42:04 +02:00
yuyi 3e40cd5baa
ast, checker, cgen: fix error for go anon fn variable call (#13776) 2022-03-20 07:45:23 +02:00
Delyan Angelov c05634ebd1
ci: fix sanitize job failures after 02b889d 2022-03-19 21:45:58 +02:00
Delyan Angelov 02b889dac3
cgen: generate smaller switch statements for sumtypes/enums with else{} 2022-03-19 21:12:27 +02:00
Delyan Angelov eb7c9cec3d
parser: short circuit if conditions in Parser.name_expr 2022-03-19 20:31:03 +02:00
Delyan Angelov 4dd68d3965
ast: small cleanup of using simple string interpolation in a string builder .write_string/1 parameter 2022-03-19 17:25:53 +02:00
Delyan Angelov 0cc63107ff
cgen: fix duplicate auto generation of free methods, add test 2022-03-19 01:01:08 +02:00
Delyan Angelov ee6b23c2a7
toml: use toml.parse_text and toml.parse_file in the tests 2022-03-18 23:32:06 +02:00
yuyi 5237d1d446
cgen: fix error for empty interface (#13764) 2022-03-18 22:41:06 +02:00
Larpon 156efec278
toml: deprecate input.auto_config() and toml.parse() (#13770) 2022-03-18 22:33:51 +02:00
yuyi 3e41be1ff4
checker: minor cleanup in check_or_last_stmt() (#13763) 2022-03-18 22:27:53 +02:00
Delyan Angelov 1734e72638
v.vmod: make the v.mod parser more robust, show line numbers in errors, add tests 2022-03-18 22:23:11 +02:00
yuyi 5f79fa8a30
checker: handle invalid smartcast with if/match none ident or selector (fix #12317) (#13762) 2022-03-18 17:50:54 +03:00
Nick Treleaven f903ef24e8
cgen: simplify slicing fixed array (#13767) 2022-03-18 17:50:30 +03:00
yuyi bb2ddb98a3
parser: check if guard condition (#13765) 2022-03-18 17:49:20 +03:00
Delyan Angelov 54b0a2aa62
toml: fix toml.scanner.new_simple/1 to *always* create a scanner, based on text, not a file path 2022-03-18 16:14:44 +02:00
Delyan Angelov 0ca87ad09f
parser: fix small performance regression after 1d83ab6b (by avoiding needless interpolation in hot paths) 2022-03-18 12:52:03 +02:00
Delyan Angelov 236bcda549
tools: speedup `v fmt -verify` when there are no file differences, avoiding diff.color_compare_files 2022-03-18 12:15:55 +02:00
Delyan Angelov 817bedec5d
checker: show available sumtype variants in match branches on typos 2022-03-18 11:50:28 +02:00
Nick Treleaven 00563a130d
cgen: fix double evaluation of rvalue array expression in slice (#13737) 2022-03-18 11:43:15 +02:00
ylluminate d87b5d40b6
docs: add installation-issues discussion in README (#13761) 2022-03-18 11:32:56 +02:00
Hunam 8a2d3f6470
strings: add a `Builder.ensure_cap()` method (#13755) 2022-03-18 10:36:53 +02:00
yuyi 136f39a2d4
cgen: cleanup in if_expr() (#13754) 2022-03-17 01:09:49 +02:00
Delyan Angelov 7a4715288c
checker: make the errors for call expression shared/mut mismatches more detailed 2022-03-16 22:45:35 +02:00
yuyi 7f62346213
cgen: fix error for if expr returning sumtype (#13752) 2022-03-16 15:43:17 +02:00
yuyi 315e07abf6
checker: minor cleanup in match_expr() (#13753) 2022-03-16 15:39:57 +02:00
yuyi 33167960ed
checker: check the sumtype mismatch returned by match expr (#13751) 2022-03-16 09:31:38 +02:00
yuyi 57cba4d3f0
ast: minor cleanup in is_blank_ident() (#13748) 2022-03-16 09:30:37 +02:00
Delyan Angelov 089c93b613
x: add a mostly empty vlib/x/x.v file, to workaround a `v doc` bug
The bug is that `v doc` ignores README.md in a folder without .v files,
leading to tree nodes with empty # links and no content.
2022-03-15 20:19:39 +02:00
yuyi 49155ec312
parser: notice unnecessary parenthesis of reference (fix #11179) (#13739) 2022-03-15 16:11:53 +02:00
yuyi 92cafd8851
checker: check invalid 'mut' keyword in infix expr (#13742) 2022-03-15 14:50:17 +03:00
yuyi 1d83ab6be1
parser: check using invalid keyword with none ident (#13743) 2022-03-15 12:58:03 +02:00
playX 78b1cbefff
builtin.wasm_bare: fix malloc invocation (#13740) 2022-03-15 12:55:39 +02:00
pancake c5174c2c69
doc: fix minor typos in build-c (#13738) 2022-03-15 08:14:46 +02:00
Nick Treleaven 34dd4f34ab
checker: fix cgen error on sliced references (#13736) 2022-03-14 19:52:37 +02:00
yuyi ea3c0166c0
ast: fix error for typeof aggregate (#13735) 2022-03-14 18:42:47 +02:00
serg-meus d6eb6d5bae
doc: update struct access modifiers (#13734) 2022-03-14 18:38:36 +02:00
yuyi dbb18e3656
parser: fix error for match branch with array expression (#13733) 2022-03-14 16:19:05 +02:00
pancake a1d0db792e
native: initial support for typeof() expressions (#13730) 2022-03-14 15:15:06 +02:00
kylepritchard a8f6574471
math: allow i64 in digits function and add count_digits function (#13729) 2022-03-14 10:41:01 +02:00
playX c8b0f51c13
builtin.wasm_bare: use walloc as malloc/free implementation (#13731) 2022-03-14 09:20:20 +02:00
Delyan Angelov 4d99157cd5
ci: add go2v build & test job to other_ci.yml 2022-03-13 19:03:42 +02:00
yuyi f7feb634d2
checker: fix error for if mut with immutable variable (#13728) 2022-03-13 16:33:50 +02:00
Mihai Galos 9495aacf3e
datatypes.fsm: add a fsm_graph.v tool (#13723) 2022-03-13 11:40:03 +02:00
Adam Oates 424ef0b2b8
stbi: fixed panic when trying to load JPG (#13724) 2022-03-13 09:57:34 +02:00
yuyi 27f9bc9ba0
checker: check error for match mut with immutable variable (fix #9704 #8976) (#13725) 2022-03-13 09:53:29 +02:00
Delyan Angelov 83762fa4a4
native: align the disassembly/comment column in the `-v -b native` output 2022-03-12 11:09:09 +02:00
Subhomoy Haldar 40504e8600
rand: further bridge gap b/w rand module and PRNG interface (#13719) 2022-03-12 09:41:12 +02:00
Delyan Angelov a3e9409196
strconv: fix a double free bug in v_sprintf/remove_tail_zeros_old, reduce leaks 2022-03-11 19:32:08 +02:00
yuyi 795fe5844c
strconv: fix strconv.v_printf() (#13716) 2022-03-11 17:00:57 +02:00
yuyi 10ab758aa7
ast: minor cleanup in pref_arch_to_table_language() (#13714) 2022-03-11 14:56:48 +02:00
Delyan Angelov 8dc4b1d9a3
builtin: use malloc_noscan more (for map metas and in []byte.hex()) 2022-03-11 11:26:22 +02:00
yuyi 1993bf2a12
parser: cleanup map syntax (#13713) 2022-03-11 12:15:52 +03:00
yuyi c1c3ae2a18
parser: minor cleanup in fn_args() (#13711) 2022-03-11 10:42:03 +02:00
yuyi 3f351036a2
parser: fix error for fn with type only argument (fix #13704) (#13709) 2022-03-10 22:52:06 +02:00
yuyi dd06698ee3
ast: rename TypeSymbol.is_public to TypeSymbol.is_pub (#13710) 2022-03-10 22:18:57 +02:00
Delyan Angelov f3388df577
ci: fix dump_expression.vv when v is actually vprod (-‸ლ) 2022-03-10 18:13:00 +02:00
Delyan Angelov e8c8f0e7c0
v.ast: fix `dump(os.real_path(Makefile))` printing `main.os.real_path` 2022-03-10 11:24:46 +02:00
Nick Treleaven 4bea35b028
vlib/arrays: fix `copy` to not use memcpy for array, map, string (#13703) 2022-03-10 01:30:51 +03:00
JalonSolov de2fc87995
os: handle trailing backslash on windows path when quoting (#13705) 2022-03-10 01:29:37 +03:00
Nick Treleaven 7231a3f135
vlib: add `mut` for the first parameter of builtin.copy, arrays.copy and crypto (#13702) 2022-03-09 20:26:00 +02:00
yuyi 4c33003f86
checker: check error for infix compare optional (#13701) 2022-03-09 20:20:21 +02:00
Nick Treleaven 54de04a916
arrays: improve fold/reduce docs (#13700) 2022-03-09 20:04:49 +02:00
yuyi 6c7243f2f7
checker: remove redundant 'c.expected_type = ast.void_type' (#13687) 2022-03-09 12:33:23 +02:00
Mihai Galos d5b087de10
vlib: add a datatypes.fsm module (#13668) 2022-03-09 12:14:54 +02:00
pancake 3f1e232c9b
native: support comparing two idents and avoid printing idents (#13686) 2022-03-08 19:52:30 +02:00
Delyan Angelov 10474f35f6
net.http: clarify error message in Request.ssl_do 2022-03-08 18:17:34 +02:00
Delyan Angelov 137fade014
Makefile: support CFLAGS and LDFLAGS for the vc/v.c to v bootstrap. 2022-03-08 14:48:20 +02:00
yuyi 3fe8204062
checker: fix if expr with enum value (#13685) 2022-03-08 11:55:17 +02:00
Delyan Angelov f6aba9a3fe
util: make check_module_is_installed more robust to ~/.vmodules paths with spaces 2022-03-08 11:33:03 +02:00
yuyi cea3149369
checker: fix match expr with enum type value (#13683) 2022-03-08 09:50:17 +02:00
Nick Treleaven 17fcc788f2
arrays: add generic copy fn (#13677) 2022-03-08 09:44:04 +02:00
Delyan Angelov beb1b8ce1b
tools: add `v scan file.v` 2022-03-07 18:25:38 +02:00
pancake b20c911d3e
native: generate relocatable ELFs and support relative strings (#13671) 2022-03-07 18:24:01 +02:00
Subhomoy Haldar 0fd4c699dd
tools: modify .gitattributes to categorize *.vsh and v.mod files properly (#13674) 2022-03-07 18:15:18 +02:00
yuyi e6270b05dc
checker: check unsigned integer compared with negative value (#13670) 2022-03-07 10:26:40 +02:00
Alexander Medvednikov 36ec47cd20 all: replace "NB:" with "Note:" (docs/comments) 2022-03-06 20:01:22 +03:00
Delyan Angelov f74b65b63f
docs: change term.input to term.ui in vlib/term/README.md 2022-03-06 15:50:22 +02:00
yuyi c8e33ad219
cgen: fix error for array of reference auto_str (#13665) 2022-03-06 12:15:31 +02:00
Delyan Angelov b0f651bf81
sync: enable tcc compilation of sync programs on Amazon Linux 2 (and other Red Hat distros like CentOS) by default (#13664) 2022-03-05 19:13:47 +02:00
yuyi 6380b9eb15
cgen: minor cleanup of struct.v (#13661) 2022-03-05 17:19:20 +02:00
yuyi 22fda7c3dd
cgen: fix error for time struct init with update (#13660) 2022-03-05 13:28:48 +02:00
yuyi 8136157f87
checker: fix error for 'or expr with nested match expr' (#13658) 2022-03-05 13:06:08 +02:00
Ned 0e5ae7126f
x/json2: fix decoder errors (#13655)
* x/json2: fix decoder errors, refactoring

* x/json2: add error-catching tests

* x/json2: add missing docs

* x/json2: fmt
2022-03-05 13:02:43 +02:00
kahsa 3ef437e679
sokol: reorder and add missing funcs (#13652) 2022-03-04 14:39:38 +03:00
Ned 437fa02f27
x.json2: add customized JSON output capability via Encoder (#13654) 2022-03-04 14:39:23 +03:00
Hunam 74d5106e8f
cli: print cli errors in red where possible (#13647) 2022-03-04 12:28:11 +02:00
yuyi f70e5bd69b
parser: check assign expr with undefined variable (#13653) 2022-03-04 10:33:14 +02:00
ChAoS_UnItY 63b41e67fa
v.parser: change body_start_pos to function declaration's lcbr, resolve #13642 (#13646) 2022-03-03 19:51:27 +02:00
Devin Bayer 9cc73fd0f8
docs: fix the .vsh doc example (#13645) 2022-03-03 19:47:05 +02:00
Delyan Angelov 4331d6dea0
v.builder: only add /DEBUG:FULL when -cflags does NOT contain custom /DEBUG options (#13643) 2022-03-03 16:47:41 +02:00
yuyi a98eebde7f
checker: add a notice for potentially incorrect smartcasts (#13644) 2022-03-03 16:36:40 +02:00
kahsa 1e76cccd48
doc: add a struct reference example (#13638) 2022-03-03 13:20:49 +02:00
yuyi ac1b31dbba
checker: fix error for array of interface init in for_in (#13636) 2022-03-03 12:32:55 +02:00
Delyan Angelov 3364f2aadf
cgen: use ADDR for sumtype conversion instead of HEAP (fix regression after 7f8f571) 2022-03-03 11:44:24 +02:00
yuyi 288b13b51d
all: cleanup smartcasts in the compiler (#13639) 2022-03-03 10:48:31 +02:00
Delyan Angelov 4e7db5bab0
v.builder: streamline get_os_cflags/0, use pref.os_from_string to centralise string -> v.pref.OS conversion 2022-03-03 10:43:50 +02:00
ChAoS_UnItY 6a3d34ae11
checker: fix #13626, when unwrapped type is fixed array, and selector expr is 'len' (#13627) 2022-03-02 20:46:18 +02:00
Delyan Angelov 57c6454656
ci: bump timeout-minutes to 30 for 'Bootstraping works' job 2022-03-02 19:51:40 +02:00
yuyi 36e80266e6
ast: fix error for 'for smartcast' - part 2 (#13635) 2022-03-02 16:01:20 +02:00
yuyi ffe6ff3cc8
cgen: fix error for print smartcast variable (#13634) 2022-03-02 12:32:54 +02:00
yuyi 22017ff8f4
parser: fix error for 'for smartcast' - part 1 (#13629) 2022-03-02 12:18:03 +02:00
yuyi 7f8f571ed2
cgen: fix error for optional cast to interface (#13623) 2022-03-01 19:21:55 +02:00
kahsa 6d57315aca
net: fix html dom debug print (#13625) 2022-03-01 19:20:40 +02:00
Ikko Ashimine aa633dab41
utf8: fix typo in utf8_util.v (#13624) 2022-03-01 19:06:48 +02:00
Delyan Angelov fd91811fe2
v.util: add set_source_for_path/2 to enable external tools to use util.formatted_error on pathless sources 2022-03-01 18:55:25 +02:00
yuyi 996bd41ce8
checker: simplify for smartcast in for_stmt() (#13619) 2022-03-01 12:31:48 +02:00
Joe Conigliaro 3b6e122d9d
all: comptime_call - update tmpl scope vars with caller scope vars after their properties got updated in checker 2022-03-01 02:13:29 +11:00
yuyi 0028e557f9
checker: cleanup smartcast in checker.v (#13618) 2022-02-28 17:06:37 +02:00
yuyi 9a2df0df0e
cgen: fix fn mut argument of interface type (#13616) 2022-02-28 13:31:04 +02:00
yuyi 013589e9fe
parser: minor cleanup in global_decl() (#13617) 2022-02-28 13:30:17 +02:00
Subhomoy Haldar a0d9e6e1c2
rand: extend PRNG interface, add buffering support (#13608) 2022-02-28 13:17:54 +02:00
yuyi efeb3e04da
ast: add table.is_sumtype_or_in_variant() (#13615) 2022-02-28 11:38:20 +03:00
yuyi 81c787ef91
checker: fix match expr with assign sumtype variable (#13614) 2022-02-28 11:37:59 +03:00
yuyi bc16c61f6f
parser: check using 'mut' on fn_decl return type (#13610) 2022-02-27 14:23:43 +02:00
yuyi 0fb1eaef04
parser: check the redefinition of built-in IError (#13606) 2022-02-26 09:52:40 +02:00
Mihai Galos 4215bb125c
examples: improve the sendbus example (#13604) 2022-02-26 09:50:44 +02:00
yuyi 0d9792bdf2
ast: cleanup in find_method_with_generic_parent() (#13600) 2022-02-26 02:11:56 +03:00
Larpon d80f5165dd
fmt: keep trailing comments after fn header decl (#13596) 2022-02-25 16:36:48 +03:00
yuyi 83ea97b1a3
parser: fix optional expr with array value (#13599) 2022-02-25 15:54:12 +03:00
Larpon 73f931b52e
fmt: improve single line const comment placement (#13595) 2022-02-25 14:46:12 +02:00
Delyan Angelov 9535d38645
ci: fix concurrency.group name for containers_ci.yml 2022-02-24 16:00:57 +02:00
Bastian Buck fa645516c3
crypto: implement Output Feedback (OFB) Mode for AES and DES (#13583) 2022-02-24 14:38:21 +02:00
Bastian Buck 0d07a64230
crypto: implement Counter (CTR) Mode for AES and DES (#13582) 2022-02-24 12:06:33 +02:00
Delyan Angelov 9523c23e14
ci: bump timeout-minutes to 25 for ci_cross.yml 2022-02-24 12:04:04 +02:00
yuyi d30ad344e8
checker: check error for array of sumtype appendding (#13593) 2022-02-24 11:07:03 +02:00
kahsa f6891c405a
doc: fix header size (#13594) 2022-02-24 10:51:10 +02:00
yuyi a28249c119
ast: fix for in iterator of generic struct (fix #13579) (#13585) 2022-02-24 10:48:52 +02:00
kahsa 9662b79662
doc: improve embedded struct section (#13574) 2022-02-23 15:54:00 +02:00
Subhomoy Haldar 114a341f5f
rand: simplify rand.PRNG, move to optional types for error handling (#13570) 2022-02-23 12:36:14 +02:00
Bastian Buck 5c0b7b0d05
crypto: implement Cipher Feedback (CFB) Mode for AES and DES (#13566) 2022-02-23 11:55:16 +03:00
yuyi b5e7cef1b1
ast: define 'const invalid_type_idx = -1' (#13573) 2022-02-23 11:54:43 +03:00
yuyi c3ec738126
checker: check struct field reference type mismatch (#13575) 2022-02-23 11:53:22 +03:00
gcxfd 838a8f2183
docs: improve the documentation for struct embedding (#13560) 2022-02-22 19:09:54 +02:00
mahdi ramezaan zaade 2712e43802
doc: add an example on how to get a cloned slice (#13567) 2022-02-22 17:22:33 +02:00
Delyan Angelov d2e8302d21
ci: show failing compilation output in draw_fns_api_test.v (make diagnostic easier) 2022-02-22 16:53:06 +02:00
yuyi 6486fffc5a
checker: cleanup `map = {}` processing (#13563) 2022-02-22 16:04:54 +02:00
Vincenzo Palazzo 6a876d4170
datatypes: small fix for the BST node constructor (#13569) 2022-02-22 15:41:30 +02:00
Larpon 1032cf5c04
checker: only cast as ast.Var if not unresolved, fixes #13561 (#13562) 2022-02-22 15:23:15 +02:00
Delyan Angelov 33d379d530
ci: vfmt vlib/net/socket.v 2022-02-22 15:21:20 +02:00
gcxfd ee1de06678
net: extract a common Socket struct, reuse it by embedding in TcpSocket & UdpSocket (#13559) 2022-02-22 10:34:38 +02:00
Vincenzo Palazzo 7bd8503170
datatypes: add a binary search tree implementation (#13453) 2022-02-22 10:28:01 +02:00
Delyan Angelov 4a765bc33b
cgen: support `-d trace_gen_source_line_info` 2022-02-21 23:04:10 +02:00
Delyan Angelov f2e5bb447e
os: remove dead code 2022-02-21 22:57:24 +02:00
yuyi 07e9ed1a1d
cgen: fix interface embedding method call (#13553) 2022-02-21 17:49:38 +02:00
playX b842e89acc
all: initial implementation of compile-time types (#13549) 2022-02-21 17:42:54 +02:00
yuyi 83cdd8bedd
ast: add comments for struct 'StructInit' and 'StructInitField' (#13551) 2022-02-21 12:48:53 +02:00
simon place 8ba4a3dd01
math.complex: make mutable the Complex.re and Complex.im fields (#13540) 2022-02-21 12:39:45 +02:00
kahsa 809772db4e
gg: improve Context scale for Android (#13545) 2022-02-21 12:12:21 +02:00
gcxfd 8b033c3993
tools: add a `-theme-dir folder/` parameter to `v doc` (#13550) 2022-02-21 12:08:46 +02:00
yuyi 04654ed518
parser: check error for defer propagate (fix #13534) (#13536) 2022-02-20 12:29:08 +02:00
yuyi 75ebac006d
cgen: fix struct init with multi nested embed update expr (#13529) 2022-02-19 20:46:44 +02:00
gcxfd dbae2d6af4
net: add UdpSocket.address() method (#13524) 2022-02-19 20:45:55 +02:00
yuyi 09f08e1fee
cgen: fix error for interface and embedded struct build (#13530) 2022-02-19 20:43:40 +02:00
eyun 67e33bf9bc
checker: make public the valid_comptime_if_os list (#13518) 2022-02-19 15:22:33 +02:00
eyun 2b974cdb97
docs: rename exec -> execute (#13514) 2022-02-19 15:20:46 +02:00
yuyi 0236931c78
cgen: fix generics with reference generic arguments (#13525) 2022-02-19 15:19:50 +02:00
Alexander Medvednikov 3fa6622ee8
doc: simplify the `filter/map` example a bit 2022-02-19 12:10:12 +03:00
Dialga bcc4de19fc
v.builder: fix cross compiling directory with spaces (#13522) 2022-02-19 10:08:41 +02:00
yuyi 0208e9672d
checker: check array sort_with_compare callback function parameters (#13511) 2022-02-19 10:06:36 +02:00
Milo 4cdb244151
docs: update urls in roadmap (#13509) 2022-02-18 14:19:06 +02:00
Delyan Angelov d86b18844e net.unix: use byte() instead of u16() cast for addr.sun_family 2022-02-18 13:47:12 +02:00
Delyan Angelov fad254dcce
ci: skip use_net_and_net_unix_together_test.v on windows 2022-02-18 12:45:32 +02:00
Delyan Angelov 3c38abc56e
rand: fix rand.uuid_v4()'s clock_seq_hi_and_reserved field 2022-02-18 12:43:38 +02:00
Delyan Angelov c9867a9ae4
net: ensure that `net` and `net.unix` can be imported together in the same program 2022-02-18 11:47:56 +02:00
yuyi 14073ac0fe
checker: fix error for array of sumtype init (#13501) 2022-02-18 11:47:24 +02:00
Subhomoy Haldar 072480352c
math.big: add get_bit, set_bit, big_mod_pow (#13507) 2022-02-18 11:53:39 +03:00
Delyan Angelov a886242700
ci: extract ubuntu-docker-musl and alpine-docker-musl-gcc to containers_ci.yml, so they can be easily turned on/off in private github actions 2022-02-18 10:31:01 +02:00
Delyan Angelov 3bcd11260f
ci: move alpine-docker-musl-gcc and ubuntu-docker-musl to other_ci.yml 2022-02-18 10:25:04 +02:00
Delyan Angelov ef5ea0ef21
ci: fix vweb failures (restore the ability to *force* vweb to listen to *only* local interfaces) 2022-02-18 10:18:04 +02:00
Alexander Medvednikov 3d46005195 tools/fast: bring back -usecache 2022-02-18 10:41:53 +03:00
Joe Conigliaro f4051e0252
checker: make sure generic struct instantiation uses a known type. closes #13506 2022-02-18 17:54:52 +11:00
Anton Zavodchikov da9331f8ff
vweb: support ipv6 (#13498) 2022-02-17 23:13:36 +03:00
Delyan Angelov eb45a321a5
tools: add cmd/tools/regress.v to simplify bisecting for regression bugs/features:
Support finding which commit introduced a regression:
       ./v run cmd/tools/regress.v --old COMMIT --command './v run /abs/path/to/regression_bug.v'

   Support also finding which commit introduced a feature (or made code compile/run):
       ./v run cmd/tools/regress.v --old COMMIT --command '! ./v run /abs/path/to/feature.v'

   NB: the '! ' is a POSIX shell feature. It may not work on Windows outside of WSL.
   Its meaning is to invert the exit code for the next command, i.e. 0 -> 1, non 0 -> 0

   If it does not work for you, you need to write a more explicit script that will exit
   with 0 code for all commits, where the feature does NOT work, and with non 0 code for
   all commits, where the feature does work.
2022-02-17 18:07:28 +02:00
Joe Conigliaro d739abbb3f
cgen: move var decl out of loop in global_decl() 2022-02-18 00:42:54 +11:00
Delyan Angelov ebb66aa82c
tools: support `git bisect run cmd/tools/oldv --bisect --command "./v run /abs/path/to/regression.v"` 2022-02-17 15:34:55 +02:00
Delyan Angelov 554a689213
ci: be more verbose when running make.bat on the CI 2022-02-17 13:26:23 +02:00
Joe Conigliaro 07b15a209a
cgen: fix for prev commit - get usecache working with clang (fix duplicate symbols) 2022-02-17 22:24:58 +11:00
Joe Conigliaro 6fc654821f
cgen: get usecache working with clang (fix duplicate symbols) 2022-02-17 22:17:07 +11:00
Delyan Angelov 245b70cabc
checker: bump iface_level_cutoff_limit to 100 (fix ci) 2022-02-17 11:46:04 +02:00
Delyan Angelov 230dc26858
checker: bump iface_level_cutoff_limit to 99 (fix ci) 2022-02-17 11:42:34 +02:00
yuyi 4f9039991f
parser: cleanup in check_undefined_variables() (#13496) 2022-02-17 10:16:52 +02:00
Delyan Angelov 901a4d8b84
checker: restrict too deep recursion, to prevent stackoverflows on windows
For v itself, the nesting levels do not exceed 15, so a limit of 40 seems reasonable.
2022-02-17 10:04:11 +02:00
yuyi 842fd7a27e
parser: check assign expr with undefined variables of struct_init (#13495) 2022-02-17 10:21:03 +03:00
Delyan Angelov 89b99ad4c3
scanner: remove the restriction for \x00 in strings (#13493) 2022-02-16 23:41:05 +02:00
blackshirt 54b10e99a1
ed25519: make public ed25519.internal.edwars25519.Element (#13488) 2022-02-16 22:56:14 +02:00
Tarcisio Gruppi f68144774d
fmt: fix map missing a comma after enum keys, leading to non parsable code (#13481) 2022-02-16 21:08:29 +02:00
Delyan Angelov d3b8ac2e46
ci: remove the -silent flag for CI jobs (the failing tests are listed at the end of the run anyway) 2022-02-16 21:02:36 +02:00
yuyi f8b8950b96
checker: check mut interface arguments (#13479) 2022-02-16 11:53:41 +02:00
Alexander Medvednikov 5a14748e7c cgen: c2v enum fix 2022-02-16 12:05:32 +03:00
Delyan Angelov 9c24d09dc3
strconv: bug fix for "${239.5:0.0f}" (#13483) 2022-02-16 11:33:29 +03:00
starryskye 6d2a88e31f
net.smtp: add STARTTLS and implicit SSL support (#13473) 2022-02-16 09:18:51 +02:00
vyrus001 d4fc8601e0
builder: fix clang failing to link on windows due to an -ftlo error (#13470) 2022-02-16 09:13:26 +02:00
Mihai Galos b8d656b308
examples: enhance the call_v_from_python example, with a fn accepting 2 f64 params (#13480) 2022-02-16 09:12:49 +02:00
blackshirt 3ac4155f0c
crypto: add an ed25519 digital signature module (#13476) 2022-02-15 21:28:14 +02:00
Delyan Angelov ff34b79d39
crypto: implement `rand.bytes(needed_bytes int) ?[]byte`, use it consistently instead of the old rand.read(), which will change to be compatible with io and the pseudo random `rand` module 2022-02-15 18:39:33 +02:00
Larpon 80444c8ec4
strings: add find_between_pair (#13468) 2022-02-15 15:12:15 +02:00
Delyan Angelov d25652fbcf
parser, ast: support -d for trace_rewrite_already_registered_symbol, trace_register_sym, trace_parse_stmt, trace_parse_comptime, trace_parse_text, trace_parse_file, trace_parse_vet_file 2022-02-15 13:20:40 +02:00
yuyi fb3dd82400
cgen: fix interface embedding complex cases (#13472) 2022-02-15 12:41:40 +02:00
mint 73cf597bec
ci: remove now-useless mlibc stuff from Vinix workflow (#13471) 2022-02-15 11:19:28 +02:00
yuyi f9fc136c24
all: rename InterfaceDecl.ifaces to InterfaceDecl.embeds (#13475) 2022-02-15 11:17:39 +02:00
crthpl e23db2f9b7
cgen: fix autogen free method for struct with shared field (#13469) 2022-02-15 03:55:06 +02:00
Delyan Angelov 89e9f8a00c
ci: fix vinix compilation to commit aa18fc0 (Meson building mlibc fails in a01546b) 2022-02-14 21:25:50 +02:00
yuyi dc0b0c83c6
ast: fix error for interface embedding call (#13466) 2022-02-14 19:22:44 +02:00
Delyan Angelov f8bf3db568
markused: always include slice_ni & substr_ni too (support s#[] and a#[] in -skip-unused) 2022-02-14 19:05:30 +02:00
igor efdbe9d92c
repl: fix `list` command deleting '/'; adapt the logo to the terminal size (#13462) 2022-02-14 16:18:20 +02:00
yuyi 8119a297f7
ast: fix error for 'struct embed is interface' (#13465) 2022-02-14 13:43:36 +02:00
yuyi b2f984280b
checker: strengthen the judgment of generic type parameters replacement, merge generic type init tests (#13460) 2022-02-14 02:38:47 +02:00
yuyi 2e0f8ee9e2
ast: fix error for struct embedding with interface (#13457) 2022-02-14 02:33:47 +02:00
Vincenzo Palazzo bf11df40e2
readline: give the possibility to ignore the empty line in the history (#13452) 2022-02-14 00:12:25 +02:00
blackshirt 57e850e932
crypto.sha512, crypto.sha256 : Make public the `write()` and `sum()` methods (#13461) 2022-02-14 00:10:50 +02:00
Delyan Angelov 74048e2f17
net: simplify the TcpConn.read_line/0 method, accumulate partially read lines, use a string builder, instead of concatenation 2022-02-13 22:42:38 +02:00
Vincenzo Palazzo 6ea4f361a1
urllib: fixed regression in the set function (#13455) 2022-02-13 15:06:00 +02:00
igor 9ff0c51e61
repl: reduce the vertical size used by V's logo, put it on the left of the info texts (#13451) 2022-02-13 11:41:36 +02:00
Delyan Angelov bad30bdd79
os: allow using XDG_CACHE_HOME for choosing the folder returned by `os.cache_dir()` on windows too 2022-02-13 11:18:51 +02:00
yuyi 5071a54b99
cgen: split up into for.v, match.v, struct.v (#13454) 2022-02-13 07:52:49 +03:00
yuyi b5379255da
checker, cgen: fix error for struct embed with fn type (#13450) 2022-02-12 20:55:40 +02:00
Ulises Jeremias Cornejo Fandos 4391ae563d
examples: improve the pendulum simulation, with several modes and diagrams (#13446) 2022-02-12 19:38:07 +02:00
Delyan Angelov a74d28ae5f
sync,ci: bump vtest retry for channel_select_6_test.v 2022-02-12 19:22:27 +02:00
Delyan Angelov 799c95dc4e
tests: filter test_ fns with params from the list of automatically run test functions (fix #13443) 2022-02-12 17:30:20 +02:00
Delyan Angelov 11a0df5bee
tests: rename struct_with_reference_alias_field.v to struct_with_reference_alias_field_test.v 2022-02-12 15:29:22 +02:00
crthpl 0eee012ae9
cgen: fix `x in shared_map` (#13442) 2022-02-12 11:55:25 +02:00
Tim Basel 37c151efe5
docs, builtin, encoding.csv: update error implementations (#13440) 2022-02-12 11:54:10 +02:00
yuyi ae0e90f5d8
cgen: fix struct init with embed field update (#13444) 2022-02-12 08:16:51 +03:00
yuyi 7178367de0
all: fix error for comptime for in field with generic fn (fix #13409) (#13439) 2022-02-11 22:00:13 +02:00
Tim Basel 9d0a5942ac
builtin: change IError `msg` and `code` to methods + fix vlib, add a deprecation notice for the old usages (#13041) 2022-02-11 15:52:33 +02:00
Vincenzo Palazzo 61024d4b75
repl: support aliased module imports too (#13423) 2022-02-11 15:03:14 +02:00
Juergen Donnerstag 654bc49d3c
os: implement win_read_string on os.Process (#13428) 2022-02-11 13:02:00 +02:00
Artem e0618f94e8
v help: add an example of using both `-prof` and `run` (#13432) 2022-02-11 11:24:07 +02:00
yuyi a21f4563b3
checker: check the arity and the kinds of the type parameters in generic struct inits (#13429) 2022-02-11 11:21:07 +02:00
Vincenzo Palazzo 7f29418c63
strconv: change atof64 to return an error, if the parsed value is not a valid number (#13424) 2022-02-10 13:27:32 +02:00
Delyan Angelov 1c19573382
ci: use 'trigger_type: manual' for Cirrus CI's arm64_task/arm64-ubuntu-tcc job 2022-02-10 13:22:18 +02:00
kahsa b205e2fc67
docs: improve the interface examples (#13422) 2022-02-10 12:28:40 +02:00
Delyan Angelov 9ed18efa53
checker: error on redefining any of the public builtin functions, not just ['print', 'println', 'eprint', 'eprintln', 'isnil', 'panic', 'exit'] (#13419) 2022-02-10 12:26:30 +02:00
Artem 43d6b97c21
docs: improve the hot reload section, add run command example (#13418) 2022-02-09 19:26:09 +02:00
yuyi f2eb50008d
parser, checker: cleanup struct short syntax processing (#13416) 2022-02-09 18:31:16 +02:00
Vincenzo Palazzo 0d1d259bb4
net.urllib: keep the query parameter order (#13405) 2022-02-09 17:36:12 +02:00
yuyi 4be3c92640
checker: check generic struct init without type parameter (#13404) 2022-02-09 14:06:45 +02:00
Delyan Angelov 356ccf247f
cgen: add an earlier error, to pin point the use of closures on windows 2022-02-09 08:35:11 +02:00
Delyan Angelov dd835acb8d
sync: add Once.do_with_param/2 method in addition to the existing Once.do/1 (workaround the absence of closures on windows) 2022-02-08 17:15:28 +02:00
Subhomoy Haldar 5d2995c4d5
tools: support `./v symlink -githubci` (#13403) 2022-02-08 13:23:10 +02:00
Delyan Angelov 1dbde05267
ci,tools: improve the precision of report-missing-fn-doc, remove dependence on sed 2022-02-08 11:30:13 +02:00
Delyan Angelov ff02f94fd6
tools: support --exclude/-e and --relative-paths/-r options in missdoc.v 2022-02-08 11:10:19 +02:00
Snavy f0806822dd
docs: add a JSON section, and subsections for encoding and decoding (#13396) 2022-02-08 10:18:40 +02:00
playX 4ef7d26133
arrays: add rotate_left and rotate_right (#13388) 2022-02-07 13:20:45 +02:00
Larpon 5df83812a0
ci: fix undoc pub fn diff output (#13389) 2022-02-07 13:18:10 +02:00
Vincenzo Palazzo 10dcb2e0d9
parser: allow embedding interfaces from other modules (#13385) 2022-02-07 00:20:34 +02:00
Delyan Angelov 1dc239227d
docs, builtin: clean up the homepage of modules.vlang.io a little, do not use //==== comments for now in builtin 2022-02-06 23:51:40 +02:00
Delyan Angelov 7f70493e1d
vdoc: show the V commit hash too, not just 0.2.4 2022-02-06 23:50:11 +02:00
Delyan Angelov 191e99c248
v.doc: use the .parse_comments mode, instead of the older .toplevel_comments (the scanner/parser is now more robust) 2022-02-06 23:49:21 +02:00
Larpon 649ecab11f
ci: add report-missing-fn-doc job, to prevent adding new undocumented pub symbols in vlib (#13386) 2022-02-06 19:52:14 +02:00
Vincenzo Palazzo d46ac40758
checker: add error for assigning `none` values (#13383) 2022-02-06 16:08:23 +02:00
Larpon 31df2c4f45
tools: tweak missdoc defaults, add CLI flags to control what's ignored (#13384) 2022-02-06 15:44:26 +02:00
kahsa fd9aa8bee6
ci: require a minimal reproducible code sample in .github/ISSUE_TEMPLATE/bug_report.md (#13382) 2022-02-06 15:41:57 +02:00
Delyan Angelov 1be0cb0306
ci: do not fail silently in the Cirrus CI / Code CI / arm64-ubuntu-tcc job 2022-02-06 14:18:24 +02:00
div72 939bc9f26f
v.parser: fix compilation of normal .v files with -translated (#13363) 2022-02-06 12:53:20 +02:00
Ikko Ashimine 31739c2586
docs: fix typo (#13381) 2022-02-06 11:39:35 +02:00
Delyan Angelov 66f21cae55
rand: add `pub fn rand.read(mut buf []byte)` and `pub fn rand.bytes(needed int) ?[]byte{}` + tests 2022-02-06 10:54:34 +02:00
yuyi ece73836aa
cgen: fix error for struct with reference alias field (#13380) 2022-02-06 10:52:36 +02:00
Vincenzo Palazzo 4e13ee22e9
repl: reproduce the void print function error (#13372) 2022-02-06 08:05:25 +02:00
Alexander Medvednikov f23d2c8cf4 cgen: c2v variadic fixes 2022-02-06 03:36:38 +03:00
div72 cec7e91714
v.parser, v.checker, v.gen: add support for [translated] tag (#13373) 2022-02-06 00:16:02 +02:00
Sandro Martini 054c8b1f13
log: update Logger interface, so that Log is usable even as a Logger instance; add a test to ensure it (#13376) 2022-02-05 22:09:55 +02:00
Delyan Angelov 5faabe7464
Revert "cgen: fix error for struct with reference alias fields (#13374)"
This reverts commit 4d485ae687.
2022-02-05 18:52:37 +02:00
yuyi 4d485ae687
cgen: fix error for struct with reference alias fields (#13374) 2022-02-05 18:23:54 +02:00
Asher 47ee292ba4
vweb: make Context.mount_static_folder_at more robust (#13361) 2022-02-05 15:10:26 +02:00
yuyi 173b4652fb
parser: check orm sql statements, using undefined variables in where expr (fix #13367) (#13368) 2022-02-05 11:32:41 +02:00
Vincenzo Palazzo c9a8d6448d
fmt: preserve formatting with comments in a empty map (#13362) 2022-02-05 10:05:35 +02:00
Vincenzo Palazzo b9fce4ef09
checker: make sure that the operator check is made on the concrete type (#13360) 2022-02-05 00:11:24 +02:00
Delyan Angelov a054f868a0
v.util: use a normalised relative file path in the error messages with /, even on windows, to make the compiler error tests more robust 2022-02-04 17:56:08 +02:00
Delyan Angelov d02c0636d8
encoding.hex: fix shift warning 2022-02-04 15:16:08 +02:00
yuyi a61b4809dc
ast, parser, checker: fix generic struct init with inconsistent generic types (#13359) 2022-02-04 14:24:38 +02:00
Delyan Angelov 89d399b035
examples: fix leak in examples/sokol/particles/, by marking s.pool and s.bin with .noslices 2022-02-03 18:52:52 +02:00
Delyan Angelov 85d36ed231
checker: stricter type casting error messages 2022-02-03 14:18:30 +02:00
kahsa ede9f29323
doc: mention []rune.string() (#13348) 2022-02-03 11:29:02 +02:00
yuyi be1e40dac0
cgen: fix error for sql statement inside fn call (fix #13330) (#13346) 2022-02-02 18:05:31 +02:00
Delyan Angelov 9344c27021
builtin: save a call to array.ensure_cap in array.insert, array.push, array.push_many in most cases 2022-02-02 11:01:07 +02:00
crthpl c0c07db7cc
cgen: fix struct field init from shared struct field (#13343) 2022-02-02 10:55:57 +02:00
penguindark c3573454d1
regex: fix bug in replace_by_fn (#13344) 2022-02-02 10:52:18 +02:00
yuyi b10b65e134
cgen: fix error for interface with multi-nested embed struct (#13345) 2022-02-02 09:11:29 +02:00
Delyan Angelov b2c299da48
vweb: support `vweb.run_at(app, localhost, 8099)` (#13337) 2022-02-01 18:41:12 +02:00
Delyan Angelov d8cce0a71d
ci: fix cgen for interface_struct_with_multi_nested_embed_test.v for gcc/clang 2022-02-01 17:12:15 +02:00
yuyi a014844050
cgen: fix error for interface with multi nested embed structs (fix #13331) (#13336) 2022-02-01 14:50:12 +02:00
Tarcisio Gruppi 51513ae19a
vfmt: keep file permissions with -w on !windows (#13334) 2022-02-01 14:49:06 +02:00
penguindark 7c1b249da0
regex: fix dot char problems on groups with * (#13333) 2022-02-01 13:49:37 +02:00
Delyan Angelov 310969a057
docs: clarify the interface methods section 2022-02-01 10:36:25 +02:00
Delyan Angelov db50e79d26
tools: implement `cgen` tag for Markdown examples in `v check-md` (#13332) 2022-01-31 22:51:04 +02:00
1792 changed files with 109145 additions and 44506 deletions

View File

@ -13,76 +13,3 @@ freebsd_task:
##tcc -v -v
echo 'Build cmd/tools/fast'
cd cmd/tools/fast && ../../../v fast.v && ./fast -clang
arm64_task:
name: Code CI / arm64-ubuntu-tcc
arm_container:
image: ubuntu:latest
install_script: apt-get update -y && apt-get install --quiet -y build-essential pkg-config wget git valgrind libsqlite3-dev libssl-dev libxi-dev libxcursor-dev libfreetype6-dev libxi-dev libxcursor-dev libgl-dev xfonts-75dpi xfonts-base libmysqlclient-dev libpq-dev gcc-10-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user
env:
DEBIAN_FRONTEND: noninteractive
VFLAGS: -cc tcc -no-retry-compilation
VJOBS: 2
script: |
set -e
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_arm64.deb
apt install --fix-missing -y ./wkhtmltox_0.12.6-1.focal_arm64.deb
# ensure that a V binary can be built, even if tcc has broken for some reason
VFLAGS='-cc gcc' make
./v -g self
./v -g self
./v -d debug_malloc -d debug_realloc -o v cmd/v
./v -cg -cstrict -o v cmd/v
#Test v->c
thirdparty/tcc/tcc.exe -version
./v -cg -o v cmd/v # Make sure vtcc can build itself twice
# - name: v self compilation
./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
# - name: v self compilation with -skip-unused
./v -skip-unused -o v2 cmd/v && ./v2 -skip-unused -o v3 cmd/v && ./v3 -skip-unused -o v4 cmd/v
# - name: v doctor
./v doctor
# - name: Verify `v test` works
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
# - name: Self tests
./v -silent test-self
## - name: Self tests (-cstrict)
## ./v -cstrict test-self
# - name: Test time functions in a timezone UTC-12
TZ=Etc/GMT+12 ./v test vlib/time/
# - name: Test time functions in a timezone UTC-3
TZ=Etc/GMT+3 ./v test vlib/time/
# - name: Test time functions in a timezone UTC+3
TZ=Etc/GMT-3 ./v test vlib/time/
# - name: Test time functions in a timezone UTC+12
TZ=Etc/GMT-12 ./v test vlib/time/
# - name: Test time functions in a timezone using daylight saving (Europe/Paris)
TZ=Europe/Paris ./v test vlib/time/
# - name: Build examples
./v -W build-examples
# - name: Test building v tools
./v -W build-tools
# - name: Test v binaries
./v build-vbinaries
# - name: Run a VSH script
./v run examples/v_script.vsh
# - name: Test v tutorials
./v tutorials/building_a_simple_web_blog_with_vweb/code/blog
# test the arm32 version of tcc
# TODO: support something like `V_EMULATOR=qemu-arm v run file.v` so that V automatically runs all binaries under qemu
./v -arch arm32 -cc arm-linux-gnueabihf-gcc-10 -o av cmd/v && qemu-arm -L /usr/arm-linux-gnueabihf ./av -arch arm32 -cc arm-linux-gnueabihf-gcc-10 -o av2 cmd/v && qemu-arm -L /usr/arm-linux-gnueabihf ./av2 -arch arm32 -cc arm-linux-gnueabihf-gcc-10 -o av3 cmd/v && qemu-arm -L /usr/arm-linux-gnueabihf ./av3 -arch arm32 -cc arm-linux-gnueabihf-gcc-10 -o av4 cmd/v
./v -arch arm32 -o closure_test.c vlib/v/tests/closure_test.v && arm-linux-gnueabihf-gcc-10 -o closure_test closure_test.c && qemu-arm -L /usr/arm-linux-gnueabihf ./closure_test

2
.gitattributes vendored
View File

@ -1,5 +1,7 @@
*.v linguist-language=V text=auto eol=lf
*.vv linguist-language=V text=auto eol=lf
*.vsh linguist-language=V text=auto eol=lf
**/v.mod linguist-language=V text=auto eol=lf
*.bat text=auto eol=crlf
Dockerfile.* linguist-language=Dockerfile
*.toml text eol=lf

View File

@ -14,6 +14,8 @@ assignees: ''
**V version:**
**OS:**
<!-- Please include the standalone minimal reproducible code.
If not, it may be closed by the administrators. -->
**What did you do?**

View File

@ -15,6 +15,8 @@ ls -lat
## try running the known failing tests first to get faster feedback
./v test vlib/builtin/string_test.v vlib/strings/builder_test.v
./v test-cleancode
./v test-self
./v build-vbinaries

View File

@ -0,0 +1,67 @@
#!/usr/bin/env -S v
module main
import os
import vab.vxt
import vab.android.ndk
fn main() {
assert ndk.found()
assert vxt.found()
work_dir := os.join_path(os.temp_dir(), 'android_cross_compile_test')
os.rm(work_dir) or {}
os.mkdir_all(work_dir) or { panic(err) }
vexe := vxt.vexe()
examples_dir := os.join_path(vxt.home(), 'examples')
v_example := os.join_path(examples_dir, 'toml.v')
ndk_version := ndk.default_version()
sysroot_path := ndk.sysroot_path(ndk_version) or { panic(err) }
include_path := os.join_path(sysroot_path, 'usr', 'include')
android_include_path := os.join_path(include_path, 'android')
//'-I"$include_path"'
cflags := ['-I"$android_include_path"', '-Wno-unused-value', '-Wno-implicit-function-declaration',
'-Wno-int-conversion']
for arch in ndk.supported_archs {
for level in ['min', 'max'] {
compiler_api := match level {
'min' {
ndk.compiler_min_api(.c, ndk_version, arch) or { panic(err) }
}
'max' {
ndk.compiler_max_api(.c, ndk_version, arch) or { panic(err) }
}
else {
panic('invalid min/max level')
}
}
os.setenv('VCROSS_COMPILER_NAME', compiler_api, true)
c_file := os.join_path(work_dir, arch + '-' + level + '.c')
o_file := os.join_path(work_dir, arch + '-' + level + '.o')
// x.v -> x.c
v_compile_cmd := '$vexe -o $c_file -os android -gc none $v_example'
vres := os.execute(v_compile_cmd)
if vres.exit_code != 0 {
panic('"$v_compile_cmd" failed: $vres.output')
}
assert os.exists(c_file)
// x.c -> x.o
compile_cmd := '$compiler_api ${cflags.join(' ')} -c $c_file -o $o_file'
cres := os.execute(compile_cmd)
if cres.exit_code != 0 {
panic('"$compile_cmd" failed: $cres.output')
}
assert os.exists(o_file)
compiler_exe_name := os.file_name(compiler_api)
println('Compiled examples/toml.v successfully for ($level) $arch $compiler_exe_name')
}
}
}

View File

@ -15,6 +15,7 @@ concurrency:
jobs:
ubuntu-tcc:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
@ -33,6 +34,7 @@ jobs:
run: |
echo $VFLAGS
make
./v test-cleancode
./v -d debug_malloc -d debug_realloc -o v cmd/v
./v -cg -cstrict -o v cmd/v
# Test v -realloc arena allocation
@ -41,7 +43,7 @@ jobs:
run: |
thirdparty/tcc/tcc.exe -version
./v -cg -o v cmd/v # Make sure vtcc can build itself twice
# ./v -silent test-all
# ./v test-all
- name: v self compilation
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
- name: v self compilation with -skip-unused
@ -54,10 +56,12 @@ jobs:
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: ./v -silent test-self
run: ./v test-self
# - name: Self tests (-cstrict)
# run: ./v -cstrict test-self
# run: V_CI_CSTRICT=1 ./v -cstrict test-self
- name: Test time functions in a timezone UTC-12
run: TZ=Etc/GMT+12 ./v test vlib/time/
- name: Test time functions in a timezone UTC-3
@ -91,6 +95,7 @@ jobs:
ubuntu-tcc-boehm-gc:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
@ -125,13 +130,15 @@ jobs:
run: |
./v -gc boehm cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests with `-gc boehm` with V compiler using Boehm-GC itself
run: ./v -gc boehm -silent test-self
run: ./v -gc boehm test-self
- name: Test leak detector
run: |
./v -gc boehm_leak -o testcase_leak vlib/v/tests/testcase_leak.vv
./testcase_leak 2>leaks.txt
grep "Found 1 leaked object" leaks.txt && grep ", sz=1000," leaks.txt
grep "Found 1 leaked object" leaks.txt && grep -P ", sz=\s?1000," leaks.txt
- name: Test leak detector not being active for `-gc boehm`
run: |
./v -gc boehm -o testcase_leak vlib/v/tests/testcase_leak.vv
@ -144,7 +151,8 @@ jobs:
[ "$(stat -c %s leaks.txt)" = "0" ]
macos:
runs-on: macOS-latest
runs-on: macOS-12
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc clang
@ -178,7 +186,7 @@ jobs:
# psql -d postgres -c 'create database customerdb;'
# psql -d customerdb -f examples/database/pg/mydb.sql
# - name: Test v->c
# run: ./v -silent test-all
# run: ./v test-all
# - name: Test v binaries
# run: ./v build-vbinaries
## - name: Test v->js
@ -188,13 +196,12 @@ jobs:
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: VJOBS=1 ./v test-cleancode
- name: Self tests
run: VJOBS=1 ./v -silent test-self
run: VJOBS=1 ./v test-self
- name: Build examples
run: ./v build-examples
- name: Build examples with -autofree
run: |
./v -autofree -o tetris examples/tetris/tetris.v
@ -202,14 +209,12 @@ jobs:
- name: v doctor
run: |
./v doctor
- name: Test ved
run: |
git clone --depth 1 https://github.com/vlang/ved
cd ved && ../v -o ved .
../v -autofree .
cd ..
# - name: Test c2v
# run: |
# git clone --depth 1 https://github.com/vlang/c2v
@ -218,7 +223,6 @@ jobs:
# ../v run tests/run_tests.vsh
# ../v -experimental -w c2v_test.v
# cd ..
- name: Build V UI examples
run: |
git clone --depth 1 https://github.com/vlang/ui
@ -227,9 +231,18 @@ jobs:
ln -s $(pwd) ~/.vmodules/ui
../v examples/rectangles.v
## ../v run examples/build_examples.vsh
- name: V self compilation with -usecache
run: |
unset VFLAGS
./v -usecache examples/hello_world.v && examples/hello_world
./v -o v2 -usecache cmd/v
./v2 -o v3 -usecache cmd/v
./v3 version
./v3 -o tetris -usecache examples/tetris/tetris.v
ubuntu:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
steps:
- uses: actions/checkout@v2
@ -252,15 +265,15 @@ jobs:
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v
# - name: Test V
# run: ./v -silent test-all
# run: ./v test-all
# - name: Test v binaries
# run: ./v build-vbinaries
## - name: Test v->js
## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
# - name: Build Vorum
# run: git clone --depth 1 https://github.com/vlang/vorum && cd vorum && ../v . && cd ..
# - name: Build vpm
# run: git clone --depth 1 https://github.com/vlang/vpm && cd vpm && ../v . && cd ..
- name: Build vpm
run: git clone --depth 1 https://github.com/vlang/vpm && cd vpm && ../v . && cd ..
- name: Freestanding
run: ./v -freestanding run vlib/os/bare/bare_example_linux.v
- name: V self compilation
@ -278,13 +291,14 @@ jobs:
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: |
./v -silent test-self
run: ./v test-self
- name: Self tests (-prod)
run: ./v -o vprod -prod cmd/v && ./vprod -silent test-self
run: ./v -o vprod -prod cmd/v && ./vprod test-self
- name: Self tests (-cstrict)
run: ./v -cc gcc -cstrict test-self
run: VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 ./v -cc gcc -cstrict test-self
- name: Build examples
run: ./v build-examples
- name: Build tetris.v with -autofree
@ -328,6 +342,7 @@ jobs:
ubuntu-clang:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc clang
@ -371,13 +386,18 @@ jobs:
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: ./v test-self
- name: Self tests (vprod)
run: |
./v -silent test-self
- name: Self tests (-prod)
run: ./v -o vprod -prod cmd/v && ./vprod -silent test-self
./v -o vprod -prod cmd/v
./vprod test-self
- name: Self tests (-cstrict)
run: ./v -cstrict test-self
run: VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 ./vprod -cstrict test-self
- name: Build examples
run: ./v build-examples
- name: Build examples with -autofree
@ -413,9 +433,11 @@ jobs:
windows-gcc:
runs-on: windows-2019
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc gcc
VERBOSE_MAKE: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
@ -426,7 +448,9 @@ jobs:
gcc --version
.\make.bat -gcc
- name: Test new v.c
run: .\v.exe -o v.c cmd/v && gcc -Werror -I ./thirdparty/stdatomic/win -municode -w v.c
run: |
.\v.exe -o v.c cmd/v
gcc -Werror -municode -w v.c
- name: Install dependencies
run: |
.\v.exe setup-freetype
@ -439,12 +463,28 @@ jobs:
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: .\v.exe test-self
# - name: Test
# run: .\v.exe test-all
- name: Test time functions in a timezone UTC-12
run: |
.\v.exe -silent test-self
# - name: Test
# run: |
# .\v.exe -silent test-all
tzutil /s "Dateline Standard Time"
./v test vlib/time/
- name: Test time functions in a timezone UTC-3
run: |
tzutil /s "Greenland Standard Time"
./v test vlib/time/
- name: Test time functions in a timezone UTC+3
run: |
tzutil /s "Russian Standard Time"
./v test vlib/time/
- name: Test time functions in a timezone UTC+12
run: |
tzutil /s "New Zealand Standard Time"
./v test vlib/time/
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
@ -456,9 +496,11 @@ jobs:
windows-msvc:
runs-on: windows-2019
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc msvc
VERBOSE_MAKE: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
@ -482,13 +524,15 @@ jobs:
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
### TODO: test-cleancode fails with msvc. Investigate why???
## - name: All code is formatted
## run: ./v test-cleancode
- name: Self tests
run: |
./v -cg cmd\tools\vtest-self.v
./v -silent test-self
./v test-self
# - name: Test
# run: |
# .\v.exe -silent test-all
# run: .\v.exe test-all
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
@ -500,11 +544,13 @@ jobs:
windows-tcc:
runs-on: windows-2019
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
VJOBS: 1
VTEST_SHOW_START: 1
VERBOSE_MAKE: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
@ -514,7 +560,9 @@ jobs:
run: |
.\make.bat -tcc
- name: Test new v.c
run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -I ./thirdparty/stdatomic/win -Werror -w -ladvapi32 -bt10 v.c
run: |
.\v.exe -o v.c cmd/v
.\thirdparty\tcc\tcc.exe -Werror -w -ladvapi32 -bt10 v.c
- name: Install dependencies
run: |
.\v.exe setup-freetype
@ -522,31 +570,23 @@ jobs:
- name: v doctor
run: |
./v doctor
- name: Verify `v test` works
run: |
.\v.exe cmd/tools/test_if_v_test_system_works.v
.\cmd\tools\test_if_v_test_system_works.exe
- name: Verify `v vlib/v/gen/c/coutput_test.v` works
run: |
.\v.exe vlib/v/gen/c/coutput_test.v
- name: Make sure running TCC64 instead of TCC32
run: ./v test .github\workflows\make_sure_ci_run_with_64bit_compiler_test.v
- name: Test ./v doc -v clipboard *BEFORE building tools*
run: ./v doc -v clipboard
- name: Test v build-tools
run: ./v -W build-tools
- name: Test ./v doc clipboard
run: ./v doc clipboard
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: ./v test-self
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
@ -554,7 +594,9 @@ jobs:
- name: Build examples
run: ./v build-examples
- name: v2 self compilation
run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v && .\v3.exe -o v4.exe cmd/v
- name: v2 self compilation with -gc boehm
run: .\v.exe -o v2.exe -gc boehm cmd/v && .\v2.exe -o v3.exe -gc boehm cmd/v && .\v3.exe -o v4.exe -gc boehm cmd/v
## ## tcc32
## - name: Build with make.bat -tcc32
@ -563,7 +605,7 @@ jobs:
## .\v.exe wipe-cache
## .\make.bat -tcc32
## - name: Test new v.c
## run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -I ./thirdparty/stdatomic/win -Werror -g -w -ladvapi32 -bt10 v.c
## run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -Werror -g -w -ladvapi32 -bt10 v.c
## - name: v doctor
## run: ./v doctor
##
@ -596,99 +638,43 @@ jobs:
## - name: v2 self compilation
## run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
alpine-docker-musl-gcc:
runs-on: ubuntu-20.04
timeout-minutes: 121
container:
# Alpine docker pre-built container
image: thevlang/vlang:alpine-build
env:
V_CI_MUSL: 1
VFLAGS: -cc gcc
volumes:
- ${{github.workspace}}:/opt/vlang
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Show Environment
run: |
echo "PWD:"
pwd
echo "ENVIRONMENT:"
env
echo "C Compiler:"
gcc --version
- name: Build V
run: CC=gcc make
- name: Test V fixed tests
run: ./v -silent test-self
# ubuntu-autofree-selfcompile:
# runs-on: ubuntu-20.04
# if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
# timeout-minutes: 121
# env:
# VFLAGS: -cc gcc
# steps:
# - uses: actions/checkout@v2
# - name: Build V
# run: make -j4
# - name: V self compilation with -autofree
# run: ./v -o v2 -autofree cmd/v && ./v2 -o v3 -autofree cmd/v && ./v3 -o v4 -autofree cmd/v
# ubuntu-autofree-selfcompile:
# runs-on: ubuntu-20.04
# timeout-minutes: 121
# env:
# VFLAGS: -cc gcc
# steps:
# - uses: actions/checkout@v2
# - name: Build V
# run: make -j4
# - name: V self compilation with -autofree
# run: ./v -o v2 -autofree cmd/v && ./v2 -o v3 -autofree cmd/v && ./v3 -o v4 -autofree cmd/v
# ubuntu-musl:
# runs-on: ubuntu-20.04
# timeout-minutes: 121
# env:
# VFLAGS: -cc musl-gcc
# V_CI_MUSL: 1
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v1
# with:
# node-version: 12.x
# - name: Install dependencies
# run: |
# sudo apt-get install --quiet -y musl musl-tools libssl-dev sqlite3 libsqlite3-dev valgrind
# - name: Build v
# run: echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
# # - name: Test v binaries
# # run: ./v build-vbinaries
# ## - name: Test v->js
# ## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
# - name: quick debug
# run: ./v -stats vlib/strconv/format_test.v
# - name: Self tests
# run: ./v -silent test-self
# Ubuntu docker pre-built container
ubuntu-musl:
runs-on: ubuntu-20.04
timeout-minutes: 121
container:
image: thevlang/vlang:ubuntu-build
env:
V_CI_MUSL: 1
V_CI_UBUNTU_MUSL: 1
VFLAGS: -cc musl-gcc
volumes:
- ${{github.workspace}}:/opt/vlang
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build V
run: |
echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Test V fixed tests
run: |
./v -silent test-self
# ubuntu-musl:
# runs-on: ubuntu-20.04
# if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
# timeout-minutes: 121
# env:
# VFLAGS: -cc musl-gcc
# V_CI_MUSL: 1
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v1
# with:
# node-version: 12.x
# - name: Install dependencies
# run: |
# sudo apt-get install --quiet -y musl musl-tools libssl-dev sqlite3 libsqlite3-dev valgrind
# - name: Build v
# run: echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
# # - name: Test v binaries
# # run: ./v build-vbinaries
# ## - name: Test v->js
# ## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
# - name: quick debug
# run: ./v -stats vlib/strconv/format_test.v
# - name: Self tests
# run: ./v test-self

View File

@ -11,10 +11,11 @@ on:
jobs:
ubuntu:
runs-on: ubuntu-20.04
timeout-minutes: 15
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
VFLAGS: -cc tcc -no-retry-compilation
B_CFLAGS: -g -std=gnu11 -I ./thirdparty/stdatomic/nix -w
B_CFLAGS: -g -std=gnu11 -w
B_LFLAGS: -lm -lpthread
steps:
- uses: actions/checkout@v2
@ -49,10 +50,11 @@ jobs:
macos:
runs-on: macos-11
timeout-minutes: 15
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
VFLAGS: -cc clang
B_CFLAGS: -g -std=gnu11 -I ./thirdparty/stdatomic/nix -w
B_CFLAGS: -g -std=gnu11 -w
B_LFLAGS: -lm -lpthread
steps:
- uses: actions/checkout@v2

View File

@ -12,7 +12,8 @@ jobs:
macos-cross:
runs-on: macOS-latest
timeout-minutes: 15
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 25
env:
VFLAGS: -cc clang
steps:
@ -41,14 +42,10 @@ jobs:
./v -os windows cmd/v
./v -os windows examples/2048/2048.v
- name: Compile to raw Android (non-graphic) compatible
run: |
# Test that V can compile non-graphic app to Android compatible code *without* using the -apk flag
./v -os android examples/toml.v
linux-cross:
runs-on: ubuntu-20.04
timeout-minutes: 15
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 25
env:
VFLAGS: -cc tcc -no-retry-compilation
steps:
@ -62,6 +59,7 @@ jobs:
sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev
sudo apt-get install --quiet -y mingw-w64 wine-stable winetricks
## sudo apt-get install --quiet -y wine32
- name: Turn off the wine crash dialog
run: winetricks nocrashdialog
@ -71,14 +69,14 @@ jobs:
- name: v.c can be compiled and run with -os cross
run: |
./v -os cross -o /tmp/v.c cmd/v
gcc -g -std=gnu11 -I ./thirdparty/stdatomic/nix -w -o v_from_vc /tmp/v.c -lm -lpthread
gcc -g -std=gnu11 -w -o v_from_vc /tmp/v.c -lm -lpthread
ls -lart v_from_vc
./v_from_vc version
- name: v_win.c can be compiled and run with -os windows
run: |
./v -os windows -o /tmp/v_win.c cmd/v
x86_64-w64-mingw32-gcc -I ./thirdparty/stdatomic/win /tmp/v_win.c -std=c99 -w -municode -o v_from_vc.exe
./v -cc msvc -os windows -o /tmp/v_win.c cmd/v
x86_64-w64-mingw32-gcc /tmp/v_win.c -std=c99 -w -municode -o v_from_vc.exe
ls -lart v_from_vc.exe
wine64 ./v_from_vc.exe version
@ -93,17 +91,10 @@ jobs:
./v -os windows examples/2048/2048.v
ls -lart examples/2048/2048.exe
- name: toml.v can be compiled to raw Android C
run: |
# Test that V can compile non-graphic app to Android compatible code *without* using the -apk flag
./v -os android examples/toml.v
windows-cross:
runs-on: windows-2019
timeout-minutes: 15
env:
VFLAGS: -cc msvc
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 25
steps:
- uses: actions/checkout@v2
- name: Build
@ -113,8 +104,8 @@ jobs:
.\make.bat -msvc
- name: TODO v_win.c can be compiled and run with -os windows
run: |
.\v.exe -os windows -showcc -o v2.exe cmd\v
.\v.exe -os windows -o v_win.c cmd\v
.\v.exe -os windows -cc msvc -showcc -o v2.exe cmd\v
.\v.exe -os windows -cc msvc -o v_win.c cmd\v
dir v2.exe
dir v_win.c
.\v2.exe version

View File

@ -16,9 +16,14 @@ on:
paths:
- '!**'
- 'cmd/tools/vtest*'
- 'cmd/tools/builders/**.v'
- 'vlib/builtin/**.v'
- 'vlib/strconv/**.v'
- 'vlib/strings/**.v'
- 'vlib/math/**.v'
- 'vlib/math/big/**.v'
- 'vlib/arrays/**.v'
- 'vlib/datatypes/**.v'
- 'vlib/os/**.v'
- 'vlib/sync/**.v'
- 'vlib/v/tests/**.v'
@ -27,18 +32,25 @@ on:
- 'vlib/v/parser/**.v'
- 'vlib/v/checker/**.v'
- 'vlib/v/gen/c/**.v'
- 'vlib/v/builder/**.v'
- 'vlib/v/cflag/**.v'
- 'vlib/v/live/**.v'
- 'vlib/v/util/**.v'
- 'vlib/v/markused/**.v'
- 'vlib/v/preludes/**.v'
- 'vlib/v/embed_file/**.v'
pull_request:
paths:
- '!**'
- 'cmd/tools/vtest*'
- 'cmd/tools/builders/**.v'
- 'vlib/builtin/**.v'
- 'vlib/strconv/**.v'
- 'vlib/strings/**.v'
- 'vlib/math/**.v'
- 'vlib/math/big/**.v'
- 'vlib/arrays/**.v'
- 'vlib/datatypes/**.v'
- 'vlib/os/**.v'
- 'vlib/sync/**.v'
- 'vlib/v/tests/**.v'
@ -47,9 +59,11 @@ on:
- 'vlib/v/parser/**.v'
- 'vlib/v/checker/**.v'
- 'vlib/v/gen/c/**.v'
- 'vlib/v/builder/**.v'
- 'vlib/v/cflag/**.v'
- 'vlib/v/live/**.v'
- 'vlib/v/util/**.v'
- 'vlib/v/markused/**.v'
- 'vlib/v/preludes/**.v'
- 'vlib/v/embed_file/**.v'
@ -60,6 +74,7 @@ concurrency:
jobs:
tests-sanitize-undefined-clang:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 180
env:
VFLAGS: -cc clang
@ -77,7 +92,9 @@ jobs:
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install clang
- name: Build V
run: make -j4 && ./v -cg -cstrict -o v cmd/v
run: make && ./v -cg -cstrict -o v cmd/v
- name: Ensure code is well formatted
run: ./v test-cleancode
- name: Self tests (-fsanitize=undefined)
run: ./v -cflags "-fsanitize=undefined" -o v2 cmd/v && ./v2 -cflags -fsanitize=undefined test-self
- name: Build examples (V compiled with -fsanitize=undefined)
@ -85,6 +102,7 @@ jobs:
tests-sanitize-undefined-gcc:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 180
env:
VFLAGS: -cc gcc
@ -101,7 +119,9 @@ jobs:
sudo apt-get install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
- name: Build V
run: make -j4 && ./v -cg -cstrict -o v cmd/v
run: make && ./v -cg -cstrict -o v cmd/v
- name: Ensure code is well formatted
run: ./v test-cleancode
- name: Self tests (-fsanitize=undefined)
run: ./v -cflags "-fsanitize=undefined" -o v2 cmd/v && ./v2 -cflags -fsanitize=undefined test-self
- name: Build examples (V compiled with -fsanitize=undefined)
@ -109,6 +129,7 @@ jobs:
tests-sanitize-address-clang:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 180
env:
VFLAGS: -cc clang
@ -126,7 +147,9 @@ jobs:
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install clang
- name: Build V
run: make -j4 && ./v -cg -cstrict -o v cmd/v
run: make && ./v -cg -cstrict -o v cmd/v
- name: Ensure code is well formatted
run: ./v test-cleancode
- name: Self tests (-fsanitize=address)
run: ASAN_OPTIONS=detect_leaks=0 ./v -cflags "-fsanitize=address,pointer-compare,pointer-subtract" test-self
- name: Self tests (V compiled with -fsanitize=address)
@ -138,6 +161,7 @@ jobs:
tests-sanitize-address-msvc:
runs-on: windows-2019
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 180
env:
VFLAGS: -cc msvc
@ -154,6 +178,11 @@ jobs:
echo $VFLAGS
.\make.bat -msvc
.\v.exe self
- name: Ensure code is well formatted
run: |
.\v.exe fmt -verify vlib/builtin/ vlib/v/scanner/ vlib/v/parser/ vlib/v/gen/
## TODO: check to see why `v test-cleancode` does not work with msvc on windows
## - name: Install dependencies
## run: |
## .\v.exe setup-freetype
@ -164,6 +193,7 @@ jobs:
tests-sanitize-address-gcc:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 180
env:
VFLAGS: -cc gcc
@ -181,7 +211,9 @@ jobs:
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install clang
- name: Build V
run: make -j4 && ./v -cg -cstrict -o v cmd/v
run: make && ./v -cg -cstrict -o v cmd/v
- name: Ensure code is well formatted
run: ./v test-cleancode
- name: Self tests (-fsanitize=address)
run: ASAN_OPTIONS=detect_leaks=0 ./v -cflags -fsanitize=address test-self
- name: Self tests (V compiled with -fsanitize=address)
@ -193,9 +225,10 @@ jobs:
tests-sanitize-memory-clang:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 180
env:
VFLAGS: -cc clang
VFLAGS: -cc clang -gc none
VJOBS: 1
VTEST_SHOW_START: 1
steps:
@ -210,11 +243,14 @@ jobs:
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install clang
- name: Build V
run: make -j4 && ./v -cc clang -cg -cstrict -o v cmd/v
run: make && ./v -cc clang -cg -cstrict -o v cmd/v
- name: Ensure code is well formatted
run: ./v test-cleancode
- name: Self tests (-fsanitize=memory)
run: ./v -cflags -fsanitize=memory test-self
- name: Self tests (V compiled with -fsanitize=memory)
run:
./v -cflags -fsanitize=memory -o v cmd/v && ./v -cc tcc test-self -msan-compiler
run: |
./v -cflags -fsanitize=memory -o v cmd/v
./v -cc tcc test-self -msan-compiler
- name: Build examples (V compiled with -fsanitize=memory)
run: ./v build-examples

View File

@ -0,0 +1,36 @@
name: vlang benchmarks
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
jobs:
run:
name: Run
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install google benchmark
run: |
git clone https://github.com/google/benchmark.git
cd benchmark
cmake -E make_directory "build"
cmake -E chdir "build" cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../
sudo cmake --build "build" --config Release --target install
- name: Run V benchmark
run: |
make
sudo ./v symlink
git clone https://github.com/vincenzopalazzo/benchmarks.git
cd benchmarks
make vdep && make v
- uses: actions/upload-artifact@v3
with:
name: vlang-benchmark
path: benchmarks/vlang/*.json

View File

@ -0,0 +1,82 @@
name: Containers CI
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
concurrency:
group: build-containers-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
alpine-docker-musl-gcc:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 181
container:
# Alpine docker pre-built container
image: thevlang/vlang:alpine-build
env:
V_CI_MUSL: 1
VFLAGS: -cc gcc
volumes:
- ${{github.workspace}}:/opt/vlang
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Show Environment
run: |
echo "PWD:"
pwd
echo "ENVIRONMENT:"
env
echo "C Compiler:"
gcc --version
- name: Build V
run: CC=gcc make
- name: All code is formatted
run: ./v test-cleancode
- name: Run only essential tests
run: VTEST_JUST_ESSENTIAL=1 ./v test-self
ubuntu-docker-musl:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
container:
image: thevlang/vlang:ubuntu-build
env:
V_CI_MUSL: 1
V_CI_UBUNTU_MUSL: 1
VFLAGS: -cc musl-gcc -gc none
volumes:
- ${{github.workspace}}:/opt/vlang
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build V
run: |
echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Test V fixed tests
run: ./v test-self

View File

@ -25,16 +25,17 @@ jobs:
.\v.exe setup-freetype
.\.github\workflows\windows-install-sqlite.bat
- name: v doctor
run: |
./v doctor
run: ./v doctor
- name: Verify `v test` works
run: |
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: |
./v -cg cmd\tools\vtest-self.v
./v -silent test-self
./v test-self
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
@ -43,4 +44,3 @@ jobs:
run: ./v build-examples
- name: v2 self compilation
run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v

View File

@ -14,5 +14,25 @@ jobs:
run: make
- name: Check markdown line length & code examples
run: ./v check-md -hide-warnings .
## NB: -hide-warnings is used here, so that the output is less noisy,
## thus real errors are easier to spot.
## NB: -hide-warnings is used here, so that the output is less noisy,
## thus real errors are easier to spot.
report-missing-fn-doc:
runs-on: ubuntu-20.04
timeout-minutes: 5
env:
MOPTIONS: --relative-paths --exclude /vlib/v/ --exclude /builtin/linux_bare/ --exclude /testdata/ --exclude /tests/
steps:
- uses: actions/checkout@v2
- name: Build V
run: make
- name: Checkout previous v
uses: actions/checkout@v2
with:
repository: vlang/v
path: pv
- name: Check against parent commit
run: |
./v missdoc --diff $MOPTIONS pv/vlib vlib

View File

@ -10,6 +10,7 @@ on:
jobs:
build-vc:
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
env:
VREPO: github.com/vlang/vc.git
steps:
@ -31,7 +32,7 @@ jobs:
rm -rf vc/v.c vc/v_win.c
./v -o vc/v.c -os cross cmd/v
./v -o vc/v_win.c -os windows cmd/v
./v -o vc/v_win.c -os windows -cc msvc cmd/v
sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v.c
sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v_win.c

View File

@ -11,6 +11,7 @@ on:
jobs:
gg-regressions:
runs-on: ubuntu-18.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 10
env:
VFLAGS: -cc tcc
@ -20,25 +21,24 @@ jobs:
uses: actions/checkout@v2
- name: Build local v
run: make -j4
run: make
- uses: openrndr/setup-opengl@v1.1
- name: Setup dependencies
run: |
# imagemagick : convert, mogrify
# xvfb : xvfb (installed by openrndr/setup-opengl@v1.1)
# openimageio-tools : idiff
# libxcursor-dev libxi-dev : V gfx deps
# mesa-common-dev : For headless rendering
# freeglut3-dev : Fixes graphic apps compilation with tcc
sudo apt-get update
sudo apt-get install imagemagick openimageio-tools mesa-common-dev libxcursor-dev libxi-dev freeglut3-dev
wget https://raw.githubusercontent.com/tremby/imgur.sh/c98345d/imgur.sh
git clone https://github.com/Larpon/gg-regression-images gg-regression-images
chmod +x ./imgur.sh
- uses: openrndr/setup-opengl@v1.1
- uses: actions/checkout@v2
with:
repository: Larpon/gg-regression-images
path: gg-regression-images
- name: Sample and compare
id: compare
continue-on-error: true
@ -50,4 +50,5 @@ jobs:
if: steps.compare.outcome != 'success'
run: |
./imgur.sh /tmp/fail.png
./imgur.sh /tmp/diff.png
exit 1

View File

@ -0,0 +1,36 @@
name: native backend CI
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
concurrency:
group: native-backend-ci-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
native-backend:
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11, macos-12, windows-2016, windows-2019, windows-2022]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Build V with make.bat
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
.\make.bat
.\v.exe symlink -githubci
- name: Build V with make
if: ${{ !startsWith(matrix.os, 'windows') }}
run: |
make
./v symlink -githubci
- name: Test the native backend
run: v test vlib/v/gen/native/

View File

@ -15,6 +15,7 @@ concurrency:
jobs:
no-gpl-by-accident:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
@ -24,6 +25,7 @@ jobs:
code-formatting:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 15
env:
VFLAGS: -cc gcc
@ -34,12 +36,13 @@ jobs:
- name: Build local v
run: make -j4
- name: v test-cleancode
run: ./v -silent test-cleancode
run: ./v test-cleancode
- name: v test-fmt
run: ./v -silent test-fmt
run: ./v test-fmt
performance-regressions:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 15
env:
VFLAGS: -cc gcc
@ -64,6 +67,7 @@ jobs:
misc-tooling:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
@ -71,15 +75,24 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 10
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install --quiet -y xfonts-75dpi xfonts-base
sudo apt-get install --quiet -y libsodium-dev libssl-dev sqlite3 libsqlite3-dev postgresql libpq-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev xfonts-75dpi xfonts-base
sudo apt-get install --quiet -y g++-9
- name: Build v
run: make
- name: g++ version
run: g++-9 --version
- name: V self compilation with g++
run: ./v -cc g++-9 -no-std -cflags -std=c++11 -o v2 cmd/v && ./v2 -cc g++-9 -no-std -cflags -std=c++11 -o v3 cmd/v
## - name: Running tests with g++
## run: ./v -cc g++-9 test-self
- name: Ensure V can be compiled with -autofree
run: ./v -autofree -o v2 cmd/v ## NB: this does not mean it runs, but at least keeps it from regressing
@ -97,25 +110,11 @@ jobs:
echo "compiling shader $f.glsl ..."; \
./sokol-shdc --input $f.glsl --output $f.h --slang glsl330 ; \
done
for vfile in examples/sokol/0?*/*.v; do echo "compiling $vfile ..."; ./v $vfile ; done
- name: Install C++ dependencies
run: |
sudo apt-get install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install --quiet -y valgrind g++-9
- name: Build V
run: make -j4
- name: g++ version
run: g++-9 --version
- name: V self compilation with g++
run: ./v -cc g++-9 -no-std -cflags -std=c++11 -o v2 cmd/v && ./v2 -cc g++-9 -no-std -cflags -std=c++11 -o v3 cmd/v
## - name: Running tests with g++
## run: ./v -cc g++-9 -silent test-self
./v should-compile-all examples/sokol/*.v examples/sokol/0?*/*.v
parser-silent:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
steps:
- uses: actions/checkout@v2
@ -152,97 +151,3 @@ jobs:
./v test-parser -S examples/regex_example_fuzz.v
./v test-parser -S examples/2048/2048_fuzz.v
v-apps-compile:
runs-on: ubuntu-20.04
timeout-minutes: 121
steps:
- uses: actions/checkout@v2
- name: Build V
run: make && sudo ./v symlink
- name: Install dependencies
run: sudo apt-get install --quiet -y libgc-dev
## vls
- name: Clone VLS
run: git clone --depth 1 https://github.com/vlang/vls
- name: Build VLS
run: pushd vls; v cmd/vls ; popd
- name: Build VLS with -prod
run: pushd vls; v -prod cmd/vls; popd
- name: Build VLS with -gc boehm -skip-unused
run: pushd vls; v -gc boehm -skip-unused cmd/vls; popd
## vsl
- name: Clone VSL
run: git clone --depth 1 https://github.com/vlang/vsl ~/.vmodules/vsl
- name: Install dependencies
run: sudo apt-get install --quiet -y --no-install-recommends gfortran liblapacke-dev libopenblas-dev libgc-dev
- name: Execute Tests using Pure V Backend
run: ~/.vmodules/vsl/bin/test
- name: Execute Tests using Pure V Backend with Pure V Math
run: ~/.vmodules/vsl/bin/test --use-cblas
- name: Execute Tests using Pure V Backend and Garbage Collection enabled
run: ~/.vmodules/vsl/bin/test --use-gc boehm
- name: Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled
run: ~/.vmodules/vsl/bin/test --use-cblas --use-gc boehm
## vtl
- name: Clone VTL
run: git clone --depth 1 https://github.com/vlang/vtl ~/.vmodules/vtl
- name: Install dependencies
run: sudo apt-get install --quiet -y --no-install-recommends gfortran liblapacke-dev libopenblas-dev libgc-dev
- name: Execute Tests using Pure V Backend
run: ~/.vmodules/vtl/bin/test
- name: Execute Tests using Pure V Backend with Pure V Math
run: ~/.vmodules/vtl/bin/test --use-cblas
- name: Execute Tests using Pure V Backend and Garbage Collection enabled
run: ~/.vmodules/vtl/bin/test --use-gc boehm
- name: Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled
run: ~/.vmodules/vtl/bin/test --use-cblas --use-gc boehm
## vab
- name: Clone vab
run: git clone --depth 1 https://github.com/vlang/vab
- name: Build vab
run: cd vab; ../v ./vab.v ; cd ..
- name: Build vab with -gc boehm -skip-unused
run: cd vab; ../v -gc boehm -skip-unused ./vab.v ; cd ..
## gitly
- name: Install markdown
run: ./v install markdown
- name: Build Gitly
run: |
git clone --depth 1 https://github.com/vlang/gitly
cd gitly
../v .
# ./gitly -ci_run
../v -autofree .
../v -o x tests/first_run.v
./x
cd ..
## vex
- name: Install Vex dependencies
run: sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev
- name: Install Vex
run: mkdir -p ~/.vmodules/nedpals; git clone https://github.com/nedpals/vex ~/.vmodules/nedpals/vex
- name: Compile the simple Vex example
run: ./v ~/.vmodules/nedpals/vex/examples/simple_example.v
- name: Compile the simple Vex example with -gc boehm -skip-unused
run: ./v -gc boehm -skip-unused ~/.vmodules/nedpals/vex/examples/simple_example.v
- name: Run Vex Tests
run: ./v test ~/.vmodules/nedpals/vex
## vpm modules
- name: Install UI through VPM
run: ./v install ui
## libsodium
- name: Install libsodium-dev package
run: sudo apt-get install --quiet -y libsodium-dev
- name: Installl the libsodium wrapper through VPM
run: ./v install libsodium
- name: Test libsodium
run: ./v test ~/.vmodules/libsodium

View File

@ -16,6 +16,7 @@ jobs:
space-paths-linux:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
MY_V_PATH: '你好 my $path, @с интервали'
@ -41,6 +42,7 @@ jobs:
space-paths-macos:
runs-on: macOS-latest
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
MY_V_PATH: '你好 my $path, @с интервали'
@ -69,6 +71,7 @@ jobs:
space-paths-windows:
runs-on: windows-2022
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
MY_V_PATH: 'path with some $punctuation, and some spaces'

View File

@ -2,57 +2,56 @@ name: Periodic
on:
schedule:
- cron: '0 */2 * * *'
- cron: '0 */6 * * *'
jobs:
network-tests-ubuntu:
runs-on: ubuntu-20.04
timeout-minutes: 30
env:
V_CI_PERIODIC: 1
V_CI_PERIODIC: 1
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind
- name: Build v
run: make -j4
- name: Symlink V
run: sudo ./v symlink
## - name: Run network tests
## run: ./v -d network test vlib/net
- uses: actions/checkout@v2
- name: Install dependencies 1
run: sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev
- name: Build v
run: make
- name: Symlink V
run: sudo ./v symlink
## - name: Run network tests
## run: ./v -d network test vlib/net
network-tests-macos:
runs-on: macOS-latest
timeout-minutes: 30
env:
V_CI_PERIODIC: 1
V_CI_PERIODIC: 1
steps:
- uses: actions/checkout@v2
- name: Setup openssl library path
run: export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
- name: Build V
run: make -j4
- name: Symlink V
run: sudo ./v symlink
- name: Ensure thirdparty/cJSON/cJSON.o is compiled, before running tests.
run: ./v examples/json.v
## - name: Run network tests
## run: ./v -d network test vlib/net
- uses: actions/checkout@v2
- name: Setup openssl library path
run: export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
- name: Build V
run: make
- name: Symlink V
run: sudo ./v symlink
- name: Ensure thirdparty/cJSON/cJSON.o is compiled, before running tests.
run: ./v examples/json.v
## - name: Run network tests
## run: ./v -d network test vlib/net
network-windows-msvc:
runs-on: windows-2019
timeout-minutes: 30
env:
V_CI_PERIODIC: 1
VFLAGS: -cc msvc
V_CI_PERIODIC: 1
VFLAGS: -cc msvc
steps:
- uses: actions/checkout@v2
- name: Build
run: |
echo %VFLAGS%
echo $VFLAGS
.\make.bat -msvc
## - name: Run network tests
## run: .\v.exe -d network test vlib/net
- uses: actions/checkout@v2
- name: Build
run: |
echo %VFLAGS%
echo $VFLAGS
.\make.bat -msvc
## - name: Run network tests
## run: .\v.exe -d network test vlib/net

View File

@ -11,6 +11,7 @@ on:
jobs:
v-compiles-sdl-examples:
runs-on: ubuntu-18.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
VFLAGS: -cc tcc
@ -40,6 +41,7 @@ jobs:
- name: Build sdl examples
run: |
v shader sdl/examples/sdl_opengl_and_sokol
for example in sdl/examples/*; do
echo "v $example"
v "$example";

View File

@ -11,6 +11,7 @@ on:
jobs:
toml-module-pass-external-test-suites:
runs-on: ubuntu-18.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
TOML_BS_TESTS_PATH: vlib/toml/tests/testdata/burntsushi/toml-test

View File

@ -0,0 +1,137 @@
name: V Apps and Modules
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
concurrency:
group: build-v-apps-and-modules-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
v-apps-compile:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
steps:
- uses: actions/checkout@v2
- name: Build V
run: make && sudo ./v symlink
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y libgc-dev libsodium-dev libssl-dev sqlite3 libsqlite3-dev valgrind libfreetype6-dev libxi-dev libxcursor-dev libgl-dev xfonts-75dpi xfonts-base
sudo apt-get install --quiet -y --no-install-recommends gfortran liblapacke-dev libopenblas-dev
- name: Build V Language Server (VLS)
run: |
echo "Clone VLS"
git clone --depth 1 https://github.com/vlang/vls /tmp/vls
echo "Build VLS"
v /tmp/vls/cmd/vls
echo "Build VLS with -prod"
v -prod /tmp/vls/cmd/vls
echo "Build VLS with -gc boehm -skip-unused"
v -gc boehm -skip-unused /tmp/vls/cmd/vls
- name: Build V Coreutils
run: |
echo "Clone Coreutils"
git clone --depth 1 https://github.com/vlang/coreutils /tmp/coreutils
echo "Build Coreutils"
cd /tmp/coreutils; make
- name: Build VAB
run: |
echo "Install VAB"
v install vab
echo "Build vab"
v ~/.vmodules/vab
echo "Build vab with -gc boehm -skip-unused"
v -gc boehm -skip-unused ~/.vmodules/vab
- name: Build Gitly
run: |
echo "Install markdown"
v install markdown
echo "Clone Gitly"
git clone https://github.com/vlang/gitly /tmp/gitly
echo "Build Gitly"
v /tmp/gitly
echo "Build Gitly with -autofree"
v -autofree /tmp/gitly
echo "Run first_run.v"
v run /tmp/gitly/tests/first_run.v
# /tmp/gitly/gitly -ci_run
- name: Build libsodium
run: |
echo "Install the libsodium wrapper"
v install libsodium
echo "Test libsodium"
VJOBS=1 v test ~/.vmodules/libsodium
- name: Build VEX
run: |
echo "Install Vex"
v install nedpals.vex
echo "Compile all of the Vex examples"
v should-compile-all ~/.vmodules/nedpals/vex/examples
echo "Compile the simple Vex example with -gc boehm -skip-unused"
v -gc boehm -skip-unused ~/.vmodules/nedpals/vex/examples/simple_example.v
echo "Run Vex Tests"
v test ~/.vmodules/nedpals/vex
- name: Build go2v
run: |
echo "Clone Go2V"
git clone --depth=1 https://github.com/vlang/go2v /tmp/go2v/
echo "Build Go2V"
v /tmp/go2v/
echo "Run Go2V tests"
VJOBS=1 v -stats test /tmp/go2v/
- name: Build vlang/pdf
run: |
v install pdf
echo "PDF examples should compile"
v should-compile-all ~/.vmodules/pdf/examples
- name: Install UI through VPM
run: |
echo "Official VPM modules should be installable"
v install ui
echo "Examples of UI should compile"
v ~/.vmodules/ui/examples/build_examples.vsh
- name: Build VSL
run: |
echo "Install VSL"
v install vsl
echo "Execute Tests using Pure V Backend"
~/.vmodules/vsl/bin/test
echo "Execute Tests using Pure V Backend with Pure V Math"
~/.vmodules/vsl/bin/test --use-cblas
echo "Execute Tests using Pure V Backend and Garbage Collection enabled"
~/.vmodules/vsl/bin/test --use-gc boehm
echo "Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled"
~/.vmodules/vsl/bin/test --use-cblas --use-gc boehm
- name: Build VTL
run: |
echo "Install VTL"
v install vtl
echo "Install dependencies"
echo "Execute Tests using Pure V Backend"
~/.vmodules/vtl/bin/test
echo "Execute Tests using Pure V Backend with Pure V Math"
~/.vmodules/vtl/bin/test --use-cblas
echo "Execute Tests using Pure V Backend and Garbage Collection enabled"
~/.vmodules/vtl/bin/test --use-gc boehm
echo "Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled"
~/.vmodules/vtl/bin/test --use-cblas --use-gc boehm

View File

@ -11,6 +11,7 @@ on:
jobs:
vab-compiles-v-examples:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VAB_FLAGS: --api 30 --build-tools 29.0.0 -v 3
@ -24,20 +25,14 @@ jobs:
- name: Build V
run: make && sudo ./v symlink
- name: Checkout vab
uses: actions/checkout@v2
with:
repository: vlang/vab
path: vab
- name: Build vab
- name: Install vab
run: |
cd vab
v -g vab.v
sudo ln -s $(pwd)/vab /usr/local/bin/vab
v install vab
v -g ~/.vmodules/vab
sudo ln -s ~/.vmodules/vab/vab /usr/local/bin/vab
- name: Run tests
run: v test vab
run: v test ~/.vmodules/vab
- name: Run vab --help
run: vab --help
@ -53,3 +48,27 @@ jobs:
safe_name=$(echo "$example" | sed 's%/%-%' | sed 's%\.%-%' )
vab examples/$example -o apks/$safe_name.apk
done
v-compiles-os-android:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Build V
run: make && sudo ./v symlink
- name: Install vab
run: |
v install vab
v -g ~/.vmodules/vab
sudo ln -s ~/.vmodules/vab/vab /usr/local/bin/vab
- name: Run vab --help
run: vab --help
- name: Run vab doctor
run: vab doctor
- name: Check `v -os android` *without* -apk flag
run: .github/workflows/android_cross_compile.vsh

View File

@ -13,22 +13,25 @@ on:
jobs:
vinix-build:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
env:
VFLAGS: -gc none
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install build-essential meson -y
run: |
sudo apt-get update
sudo apt-get install build-essential meson -y
- name: Build V
run: make
- name: Clone current Vinix
run: |
git clone https://github.com/vlang/vinix.git --depth 1
- name: Clone current mlibc
run: git clone https://github.com/managarm/mlibc.git --depth=1
- name: Patch mlibc for Vinix
run: cd mlibc && patch -p1 < ../vinix/patches/mlibc/0001-Vinix-specific-changes.patch || true
- name: Install mlibc headers
run: mkdir mlibc-build && cd mlibc-build && meson --cross-file ../vinix/cross_file.txt --prefix=/ -Dheaders_only=true ../mlibc && ninja && mkdir ../mlibc-headers && DESTDIR=`realpath ../mlibc-headers` ninja install
run: git clone https://github.com/vlang/vinix.git
- name: Attempt to build the Vinix kernel (debug)
run: cd vinix/kernel && make PROD=false CFLAGS="-D__vinix__ -O2 -g -pipe -I../../mlibc-headers/include" V="../../v" && make clean
run: cd vinix/kernel && make PROD=false CFLAGS="-D__vinix__ -O2 -g -pipe" V="../../v" && make clean
- name: Attempt to build the Vinix kernel (prod)
run: cd vinix/kernel && make PROD=true CFLAGS="-D__vinix__ -O2 -g -pipe -I../../mlibc-headers/include" V="../../v" && make clean
run: cd vinix/kernel && make PROD=true CFLAGS="-D__vinix__ -O2 -g -pipe" V="../../v" && make clean

View File

@ -11,6 +11,7 @@ on:
jobs:
websocket_tests:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation

View File

@ -1,12 +1,11 @@
@echo off
curl -L https://www.sqlite.org/2020/sqlite-amalgamation-3320300.zip -o sqlite-amalgamation-3320300.zip
curl -L https://www.sqlite.org/2022/sqlite-amalgamation-3380200.zip -o sqlite-amalgamation-3380200.zip
unzip sqlite-amalgamation-3320300.zip -d thirdparty\
unzip sqlite-amalgamation-3380200.zip -d thirdparty\
del thirdparty\sqlite-amalgamation-3320300\shell.c
del thirdparty\sqlite-amalgamation-3380200\shell.c
move /y thirdparty\sqlite-amalgamation-3320300 thirdparty\sqlite
move /y thirdparty\sqlite-amalgamation-3380200 thirdparty\sqlite
dir thirdparty\sqlite

61
.woodpecker.yml 100644
View File

@ -0,0 +1,61 @@
platform: 'linux/amd64'
branches: ['master']
pipeline:
gen-vc:
# This is what the official CI uses as well
image: 'ubuntu:latest'
secrets:
- deploy_key
commands:
# Install necessary dependencies
- apt-get update -y && apt-get install openssh-client git build-essential -y
# Build the compiler
- make
# Run ssh-agent
- eval $(ssh-agent -s)
# Add ssh key
- echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add -
# Create ssh dir with proper permissions
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
# Configure git credentials
- git config --global user.email 'vbot@rustybever.be'
- git config --global user.name 'vbot'
# Verify SSH keys
- ssh-keyscan git.rustybever.be > ~/.ssh/known_hosts
# The following is copied over from the official repo's CI
# https://github.com/vlang/v/blob/master/.github/workflows/gen_vc.yml
- export "COMMIT_HASH=$(git rev-parse --short HEAD)"
- export "COMMIT_MSG=$(git log -1 --oneline --pretty='%s' HEAD)"
- rm -rf vc
- git clone --depth=1 'git@git.rustybever.be:vieter/vc.git'
- rm -rf vc/v.c vc/v_win.c
- ./v -o vc/v.c -os cross cmd/v
- ./v -o vc/v_win.c -os windows -cc msvc cmd/v
- sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v.c
- sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v_win.c
# ensure the C files are over 5000 lines long, as a safety measure
- '[ $(wc -l < vc/v.c) -gt 5000 ]'
- '[ $(wc -l < vc/v_win.c) -gt 5000 ]'
- git -C vc add v.c v_win.c
- 'git -C vc commit -m "[v:master] $COMMIT_HASH - $COMMIT_MSG"'
# in case there are recent commits:
- git -C vc pull --rebase origin main
- git -C vc push
when:
event: push
publish:
image: woodpeckerci/plugin-docker-buildx
secrets: [ docker_username, docker_password ]
settings:
repo: chewingbever/vlang
tag: latest
dockerfile: Dockerfile.builder
platforms: [ linux/arm64/v8, linux/amd64 ]
# The build can run every time, because we should only push when there's
# actual changes
when:
event: push

View File

@ -0,0 +1,32 @@
matrix:
PLATFORM:
- 'linux/amd64'
- 'linux/arm64'
platform: ${PLATFORM}
branches: ['master']
depends_on:
- 'vc'
pipeline:
build:
image: 'menci/archlinuxarm:base-devel'
commands:
# Update packages
- pacman -Syu --noconfirm
# Create non-root user to perform build & switch to their home
- groupadd -g 1000 builder
- useradd -mg builder builder
- chown -R builder:builder "$PWD"
- "echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
- su builder
# Build the package
- makepkg -s --noconfirm --needed
publish:
image: 'curlimages/curl'
secrets:
- 'vieter_api_key'
commands:
# Publish the package
- 'for pkg in $(ls -1 *.pkg*); do curl -f -XPOST -T "$pkg" -H "X-API-KEY: $VIETER_API_KEY" https://arch.r8r.be/vieter/publish; done'

View File

@ -0,0 +1,18 @@
platform: 'linux/amd64'
branches: ['master']
depends_on:
- 'vc'
pipeline:
build-publish:
image: 'woodpeckerci/plugin-docker-buildx'
secrets: [ docker_username, docker_password ]
settings:
repo: chewingbever/vlang
tag: latest
dockerfile: Dockerfile.builder
platforms: [ linux/arm64/v8, linux/amd64 ]
# The build can run every time, because we should only push when there's
# actual changes
when:
event: push

View File

@ -0,0 +1,48 @@
platform: 'linux/amd64'
branches: ['master']
pipeline:
gen-vc:
# This is what the official CI uses as well
image: 'ubuntu:latest'
secrets:
- deploy_key
commands:
# Install necessary dependencies
- apt-get update -y && apt-get install openssh-client git build-essential -y
# Build the compiler
- make
# Run ssh-agent
- eval $(ssh-agent -s)
# Add ssh key
- echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add -
# Create ssh dir with proper permissions
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
# Configure git credentials
- git config --global user.email 'vbot@rustybever.be'
- git config --global user.name 'vbot'
# Verify SSH keys
- ssh-keyscan git.rustybever.be > ~/.ssh/known_hosts
# The following is copied over from the official repo's CI
# https://github.com/vlang/v/blob/master/.github/workflows/gen_vc.yml
- export "COMMIT_HASH=$(git rev-parse --short HEAD)"
- export "COMMIT_MSG=$(git log -1 --oneline --pretty='%s' HEAD)"
- rm -rf vc
- git clone --depth=1 'git@git.rustybever.be:vieter-v/vc.git'
- rm -rf vc/v.c vc/v_win.c
- ./v -o vc/v.c -os cross cmd/v
- ./v -o vc/v_win.c -os windows -cc msvc cmd/v
- sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v.c
- sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v_win.c
# ensure the C files are over 5000 lines long, as a safety measure
- '[ $(wc -l < vc/v.c) -gt 5000 ]'
- '[ $(wc -l < vc/v_win.c) -gt 5000 ]'
- git -C vc add v.c v_win.c
- 'git -C vc commit -m "[v:master] $COMMIT_HASH - $COMMIT_MSG"'
# in case there are recent commits:
- git -C vc pull --rebase origin main
- git -C vc push
when:
event: push

View File

@ -1,6 +1,8 @@
-## V 0.2.5
-*Not yet released, changelog is not full*
- Introduce `isize` and `usize` types, deprecate `size_t` in favor of `usize`
- Introduce `isize` and `usize` types, deprecate `size_t` in favor of `usize`.
- Add `datatypes` and `datatypes.fsm` modules.
- Add `compile_error` and `compile_warn` comptime functions.
-## V 0.2.4
-*Not yet released, changelog is not full*

View File

@ -35,32 +35,35 @@ The main files are:
- Creates a parser object for each file and runs `parse()` on them.
- The correct backend is called (C, JS, native), and a binary is compiled.
2. `v/scanner` The scanner's job is to parse a list of characters and convert
2. `vlib/v/scanner` The scanner's job is to parse a list of characters and convert
them to tokens.
3. `v/token` This is simply a list of all tokens, their string values, and a
3. `vlib/v/token` This is simply a list of all tokens, their string values, and a
couple of helper functions.
4. `v/parser` The parser. It converts a list of tokens into an AST.
4. `vlib/v/parser` The parser. It converts a list of tokens into an AST.
In V, objects can be used before declaration, so unknown types are marked as
unresolved. They are resolved later in the type checker.
5. `v/table` V creates one table object that is shared by all parsers. It
5. `vlib/v/table` V creates one table object that is shared by all parsers. It
contains all types, consts, and functions, as well as several helpers to search
for objects by name, register new objects, modify types' fields, etc.
6. `v/checker` Type checker and resolver. It processes the AST and makes sure
6. `vlib/v/checker` Type checker and resolver. It processes the AST and makes sure
the types are correct. Unresolved types are resolved, type information is added
to the AST.
7. `v/gen/c` C backend. It simply walks the AST and generates C code that can be
7. `vlib/v/gen/c` C backend. It simply walks the AST and generates C code that can be
compiled with Clang, GCC, Visual Studio, and TCC.
8. `json.v` defines the json code generation. This file will be removed once V
8. `vlib/v/gen/js` JavaScript backend. It simply walks the AST and generates JS code that can be
executed on the browser or in NodeJS/Deno.
9. `vlib/v/gen/c/json.v` defines the json code generation. This file will be removed once V
supports comptime code generation, and it will be possible to do this using the
language's tools.
9. `v/gen/native` is the directory with all the machine code generation logic. It
10. `vlib/v/gen/native` is the directory with all the machine code generation logic. It
defines a set of functions that translate assembly instructions to machine code
and build the binary from scratch byte by byte. It manually builds all headers,
segments, sections, symtable, relocations, etc. Right now it only has basic
@ -90,6 +93,7 @@ making pullrequests, and you can just do normal git operations such as:
5. When finished with a feature/bugfix/change, you can:
`git checkout -b fix_alabala`
- Don't forget to keep formatting standards, run `v fmt -w YOUR_MODIFIED_FILES` before committing
6. `git push pullrequest` # (NOTE: the `pullrequest` remote was setup on step 4)
7. On GitHub's web interface, go to: https://github.com/vlang/v/pulls
@ -187,7 +191,6 @@ to create a copy of the compiler rather than replacing it with `v self`.
| `debug_codegen` | Prints automatically generated V code during the scanning phase |
| `debug_interface_table` | Prints generated interfaces during C generation |
| `debug_interface_type_implements` | Prints debug information when checking that a type implements in interface |
| `debug_embed_file_in_prod` | Prints debug information about the embedded files with `$embed_file('somefile')` |
| `print_vweb_template_expansions` | Prints vweb compiled HTML files |
| `time_checking` | Prints the time spent checking files and other related information |
| `time_parsing` | Prints the time spent parsing files and other related information |
@ -200,3 +203,4 @@ to create a copy of the compiler rather than replacing it with `v self`.
| `trace_thirdparty_obj_files` | Prints details about built thirdparty obj files |
| `trace_usecache` | Prints details when -usecache is used |
| `trace_embed_file` | Prints details when $embed_file is used |
| `embed_only_metadata` | Embed only the metadata for the file(s) with `$embed_file('somefile')`; faster; for development, *not* distribution |

33
Dockerfile.builder 100644
View File

@ -0,0 +1,33 @@
FROM alpine:3.16
ARG TARGETPLATFORM
WORKDIR /opt/vlang
ENV VVV /opt/vlang
ENV PATH /opt/vlang:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV VFLAGS -cc gcc -gc none
ENV V_PATH /opt/vlang/v
RUN ln -s /opt/vlang/v /usr/bin/v && \
apk --no-cache add \
git make gcc curl openssl \
musl-dev \
openssl-libs-static openssl-dev \
zlib-static bzip2-static xz-dev expat-static zstd-static lz4-static \
sqlite-static sqlite-dev \
libx11-dev glfw-dev freetype-dev \
libarchive-static libarchive-dev \
diffutils \
mandoc
RUN git clone https://git.rustybever.be/vieter/v /opt/vlang && \
make && \
v -version
RUN if [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \
wget -O /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc && \
chmod +x /usr/local/bin/mc ; \
fi
CMD ["v"]

View File

@ -1,10 +1,10 @@
FROM mstorsjo/llvm-mingw
LABEL maintainer="Vitaly Takmazov <vitalyster@gmail.com>"
LABEL maintainer="Delyan Angelov <delian66@gmail.com>"
COPY . .
RUN make
RUN ./v -os windows -o v.c cmd/v
RUN x86_64-w64-mingw32-gcc v.c -std=c99 -I ./thirdparty/stdatomic/win -w -municode -o v.exe
RUN x86_64-w64-mingw32-gcc v.c -std=c99 -w -municode -o v.exe
RUN file v.exe
CMD [ "bash" ]

View File

@ -5,7 +5,7 @@ TMPDIR ?= /tmp
VROOT ?= .
VC ?= ./vc
V ?= ./v
VCREPO ?= https://github.com/vlang/vc
VCREPO ?= https://git.rustybever.be/vieter/vc
TCCREPO ?= https://github.com/vlang/tccbin
VCFILE := v.c
@ -28,6 +28,9 @@ endif
ifeq ($(_SYS),Linux)
LINUX := 1
TCCOS := linux
ifneq ($(shell ldd /bin/ls | grep musl),)
TCCOS := linuxmusl
endif
endif
ifeq ($(_SYS),Darwin)
@ -76,7 +79,7 @@ endif
endif
endif
.PHONY: all clean fresh_vc fresh_tcc check_for_working_tcc
.PHONY: all clean check fresh_vc fresh_tcc check_for_working_tcc
ifdef prod
VFLAGS+=-prod
@ -84,13 +87,13 @@ endif
all: latest_vc latest_tcc
ifdef WIN32
$(CC) $(CFLAGS) -std=c99 -municode -w -I ./thirdparty/stdatomic/nix -o v1.exe $(VC)/$(VCFILE) $(LDFLAGS)
$(CC) $(CFLAGS) -std=c99 -municode -w -o v1.exe $(VC)/$(VCFILE) $(LDFLAGS)
v1.exe -no-parallel -o v2.exe $(VFLAGS) cmd/v
v2.exe -o $(V) $(VFLAGS) cmd/v
del v1.exe
del v2.exe
else
$(CC) $(CFLAGS) -std=gnu99 -w -I ./thirdparty/stdatomic/nix -o v1.exe $(VC)/$(VCFILE) -lm -lpthread $(LDFLAGS)
$(CC) $(CFLAGS) -std=gnu99 -w -o v1.exe $(VC)/$(VCFILE) -lm -lpthread $(LDFLAGS)
./v1.exe -no-parallel -o v2.exe $(VFLAGS) cmd/v
./v2.exe -o $(V) $(VFLAGS) cmd/v
rm -rf v1.exe v2.exe
@ -113,7 +116,7 @@ endif
check_for_working_tcc:
@$(TMPTCC)/tcc.exe --version > /dev/null 2> /dev/null || echo "The executable '$(TMPTCC)/tcc.exe' does not work."
fresh_vc:
rm -rf $(VC)
$(GITFASTCLONE) $(VCREPO) $(VC)
@ -164,3 +167,5 @@ selfcompile-static:
install:
@echo 'Please use `sudo ./v symlink` instead.'
check:
$(V) test-all

View File

@ -1,12 +1,19 @@
CC ?= cc
VFLAGS ?=
CFLAGS ?=
LDFLAGS ?=
.PHONY: all check
all:
rm -rf vc/
git clone --depth 1 --quiet https://github.com/vlang/vc
$(CC) -std=gnu11 -w -I ./thirdparty/stdatomic/nix -o v1 vc/v.c -lm -lexecinfo -lpthread
git clone --depth 1 --quiet https://git.rustybever.be/vieter/vc
$(CC) $(CFLAGS) -std=gnu11 -w -o v1 vc/v.c -lm -lexecinfo -lpthread $(LDFLAGS)
./v1 -no-parallel -o v2 $(VFLAGS) cmd/v
./v2 -o v $(VFLAGS) cmd/v
rm -rf v1 v2 vc/
@echo "V has been successfully built"
./v run ./cmd/tools/detect_tcc.v
check:
./v test-all

54
PKGBUILD 100644
View File

@ -0,0 +1,54 @@
# Maintainer: Jef Roosens
# This PKGBUILD is mostly copied over from the AUR
# https://aur.archlinux.org/packages/vlang-git
pkgname=vieter-v
pkgver=0.2.2.r796.gfbc02cbc5
pkgrel=1
pkgdesc='Simple, fast, safe, compiled language for developing maintainable software'
arch=('x86_64' 'aarch64')
url='https://vlang.io'
license=('MIT')
depends=('glibc')
makedepends=('git')
optdepends=('glfw: Needed for graphics support'
'freetype2: Needed for graphics support'
'openssl: Needed for http support')
provides=('vlang')
conflicts=('v' 'vlang' 'vlang-bin')
source=('vlang::git+https://git.rustybever.be/Chewing_Bever/v')
sha256sums=('SKIP')
pkgver() {
cd "${srcdir}/vlang"
# Weekly tags are considered older than semantic tags that are older than
# them, so to prevent version resolution problems we exclude weekly tags.
git describe --long --tags --exclude "weekly*" | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}
build() {
cd "${srcdir}/vlang"
# We don't require optimizations when compiling the bootstrap executable and
# -O2 actually breaks `./v self` (resulting in "cgen error:"), so we empty
# CFLAGS and LDFLAGS to ensure successful compilation.
CFLAGS="" LDFLAGS="" prod=1 make
# vpm and vdoc fail to compile with "unsupported linker option" when LDFLAGS
# is set
LDFLAGS="" ./v build-tools
}
package() {
cd "${srcdir}/vlang"
install -d "$pkgdir/usr/lib/vlang" "$pkgdir/usr/share/vlang" "$pkgdir/usr/bin"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
install -Dm755 v "$pkgdir/usr/lib/vlang"
cp -a cmd "$pkgdir/usr/lib/vlang/"
cp -a examples "$pkgdir/usr/share/vlang/"
cp -a thirdparty "$pkgdir/usr/lib/vlang/"
cp -a vlib "$pkgdir/usr/lib/vlang/"
cp v.mod "$pkgdir/usr/lib/vlang/"
ln -s /usr/lib/vlang/v "$pkgdir/usr/bin/v"
touch "$pkgdir/usr/lib/vlang/cmd/tools/.disable_autorecompilation"
}

View File

@ -4,11 +4,7 @@
</p>
<h1>The V Programming Language</h1>
[vlang.io](https://vlang.io) |
[Docs](https://github.com/vlang/v/blob/master/doc/docs.md) |
[Changelog](https://github.com/vlang/v/blob/master/CHANGELOG.md) |
[Speed](https://fast.vlang.io/) |
[Contributing & compiler design](https://github.com/vlang/v/blob/master/CONTRIBUTING.md)
[vlang.io](https://vlang.io) | [Docs](https://github.com/vlang/v/blob/master/doc/docs.md) | [Changelog](https://github.com/vlang/v/blob/master/CHANGELOG.md) | [Speed](https://fast.vlang.io/) | [Contributing & compiler design](https://github.com/vlang/v/blob/master/CONTRIBUTING.md)
</div>
<div align="center">
@ -31,7 +27,7 @@
- Easy to develop: V compiles itself in less than a second
- Performance: as fast as C (V's main backend compiles to human-readable C)
- Safety: no null, no globals, no undefined behavior, immutability by default
- C to V translation
- C to V translation ([Translating DOOM demo video](https://www.youtube.com/watch?v=6oXrz3oRoEg))
- Hot code reloading
- [Innovative memory management](https://vlang.io/#memory) ([demo video](https://www.youtube.com/watch?v=gmB8ea8uLsM))
- [Cross-platform UI library](https://github.com/vlang/ui)
@ -60,23 +56,40 @@ Unlike many other languages, V is not going to be always changing, with new feat
being introduced and old features modified. It is always going to be a small and simple
language, very similar to the way it is right now.
## Installing V from source
## Installing V - from source *(preferred method)*
### Linux, macOS, Windows, *BSD, Solaris, WSL, Android, Raspbian
### Linux, macOS, Windows, *BSD, Solaris, WSL, Android, etc.
Usually installing V is quite simple if you have an environment that already has a
functional `git` installation.
* *(* ***PLEASE NOTE:*** *If you run into any trouble or you have a different operating
system or Linux distribution that doesn't install or work immediately, please see
[Installation Issues](https://github.com/vlang/v/discussions/categories/installation-issues)
and search for your OS and problem. If you can't find your problem, please add it to an
existing discussion if one exists for your OS, or create a new one if a main discussion
doesn't yet exist for your OS.)*
To get started, simply try to execute the following in your terminal/shell:
```bash
git clone https://github.com/vlang/v
cd v
make
# HINT: Using Windows?: run make.bat in the cmd.exe shell
```
That's it! Now you have a V executable at `[path to V repo]/v`.
That should be it and you should find your V executable at `[path to V repo]/v`.
`[path to V repo]` can be anywhere.
(On Windows `make` means running `make.bat`, so make sure you use `cmd.exe`)
(As in the hint above, on Windows `make` means running `make.bat`, so make sure you use
the `cmd.exe` terminal.)
Now you can try `./v run examples/hello_world.v` (`v.exe` on Windows).
* *Trouble? Please see the note above and link to
[Installation Issues](https://github.com/vlang/v/discussions/categories/installation-issues) for help.*
V is constantly being updated. To update V, simply run:
```bash

View File

@ -1,11 +1,11 @@
## [Version 0.3](https://github.com/vlang/v/projects/5)
- [ ] [make `-autofree` the default](https://github.com/vlang/v/issues/6989)
- [x] [gc option]
- [ ] [coroutines](https://github.com/vlang/v/issues/561)
- [ ] [coroutines](https://github.com/vlang/v/discussions/11582)
- [x] channels
- [x] lock{}
- [x] thread safe arrays
- [ ] [thread safe maps](https://github.com/vlang/v/issues/6992)
- [ ] [thread safe maps](https://github.com/vlang/v/discussions/11729)
- [ ] [C2V translator](https://github.com/vlang/v/issues/6985)
- [ ] doom.v
- [x] rune type

View File

@ -83,6 +83,20 @@ This *test runner*, checks whether whole project folders, can be compiled, and r
NB: Each project in these folders, should finish with an exit code of 0,
and it should output `OK` as its last stdout line.
## `v vlib/v/tests/known_errors/known_errors_test.v`
This *test runner*, checks whether a known program, that was expected to compile,
but did NOT, due to a buggy checker, parser or cgen, continues to fail.
The negative programs are collected in the `vlib/v/tests/known_errors/testdata/` folder.
Each of them should FAIL to compile, due to a known/confirmed compiler bug/limitation.
The intended use of this, is for providing samples, that currently do NOT compile,
but that a future compiler improvement WILL be able to compile, and to
track, whether they were not fixed incidentally, due to an unrelated
change/improvement. For example, code that triggers generating invalid C code can go here,
and later when a bug is fixed, can be moved to a proper _test.v or .vv/.out pair, outside of
the `vlib/v/tests/known_errors/testdata/` folder.
## Test building of actual V programs (examples, tools, V itself)
* `v build-tools`

View File

@ -14,13 +14,13 @@ fn main() {
mut checksum := u64(0)
mut start_pos := 0
mut bgenerating := benchmark.start()
mut bytepile := []byte{}
mut bytepile := []u8{}
for _ in 0 .. sample_size * max_str_len {
bytepile << byte(rand.int_in_range(40, 125))
bytepile << u8(rand.int_in_range(40, 125) or { 40 })
}
mut str_lens := []int{}
for _ in 0 .. sample_size {
str_lens << rand.int_in_range(min_str_len, max_str_len)
str_lens << rand.int_in_range(min_str_len, max_str_len) or { min_str_len }
}
bgenerating.measure('generating strings')
println('Hashing each of the generated strings...')
@ -30,7 +30,7 @@ fn main() {
checksum = 0
for len in str_lens {
end_pos := start_pos + len
checksum ^= wyhash.wyhash_c(unsafe { &byte(bytepile.data) + start_pos }, u64(len),
checksum ^= wyhash.wyhash_c(unsafe { &u8(bytepile.data) + start_pos }, u64(len),
1)
start_pos = end_pos
}

View File

@ -43,7 +43,7 @@ fn main() {
vexe := pref.vexe_path()
vroot := os.dir(vexe)
util.set_vroot_folder(vroot)
os.chdir(vroot) ?
os.chdir(vroot)?
cmd := diff.find_working_diff_command() or { '' }
mut app := App{
diff_cmd: cmd

View File

@ -4,12 +4,14 @@ fn main() {
exit(0)
}
println('
NB: `tcc` was not used, so unless you install it yourself, your backend
$if !macos {
println('
Note: `tcc` was not used, so unless you install it yourself, your backend
C compiler will be `cc`, which is usually either `clang`, `gcc` or `msvc`.
These C compilers, are several times slower at compiling C source code,
compared to `tcc`. They do produce more optimised executables, but that
is done at the cost of compilation speed.
')
}
}

View File

@ -4,8 +4,7 @@
import os
import time
// TODO -usecache
const voptions = ' -skip-unused -show-timings -stats '
const voptions = ' -usecache -skip-unused -show-timings -stats '
const exe = os.executable()
@ -16,7 +15,7 @@ const vdir = @VEXEROOT
fn main() {
dump(fast_dir)
dump(vdir)
os.chdir(fast_dir) ?
os.chdir(fast_dir)?
if !os.exists('$vdir/v') && !os.is_dir('$vdir/vlib') {
println('fast.html generator needs to be located in `v/cmd/tools/fast`')
}
@ -29,37 +28,37 @@ fn main() {
return
}
}
// Fetch the last commit's hash
// fetch the last commit's hash
commit := exec('git rev-parse HEAD')[..8]
if !os.exists('table.html') {
os.create('table.html') ?
os.create('table.html')?
}
mut table := os.read_file('table.html') ?
mut table := os.read_file('table.html')?
if os.exists('website/index.html') {
uploaded_index := os.read_file('website/index.html') ?
uploaded_index := os.read_file('website/index.html')?
if uploaded_index.contains('>$commit<') {
println('nothing to benchmark')
exit(1)
return
}
}
// for i, commit in commits {
message := exec('git log --pretty=format:"%s" -n1 $commit')
// println('\n${i + 1}/$commits.len Benchmarking commit $commit "$message"')
println('\nBenchmarking commit $commit "$message"')
// Build an optimized V
// println('Checking out ${commit}...')
// exec('git checkout $commit')
// build an optimized V
println(' Building vprod...')
os.chdir(vdir) ?
os.chdir(vdir)?
if os.args.contains('-noprod') {
exec('./v -o vprod cmd/v') // for faster debugging
} else {
exec('./v -o vprod -prod -prealloc cmd/v')
}
// cache vlib modules
exec('$vdir/v wipe-cache')
exec('$vdir/v -o v2 -prod cmd/v')
// measure
diff1 := measure('$vdir/vprod $voptions -o v.c cmd/v', 'v.c')
mut tcc_path := 'tcc'
@ -72,23 +71,24 @@ fn main() {
if os.args.contains('-clang') {
tcc_path = 'clang'
}
diff2 := measure('$vdir/vprod $voptions -cc $tcc_path -o v2 cmd/v', 'v2')
diff3 := 0 // measure('$vdir/vprod -native $vdir/cmd/tools/1mil.v', 'native 1mil')
diff4 := measure('$vdir/vprod -usecache $voptions -cc clang examples/hello_world.v',
'hello.v')
vc_size := os.file_size('v.c') / 1000
// scan/parse/check/cgen
scan, parse, check, cgen, vlines := measure_steps(vdir)
// println('Building V took ${diff}ms')
commit_date := exec('git log -n1 --pretty="format:%at" $commit')
date := time.unix(commit_date.int())
//
os.chdir(fast_dir) ?
mut out := os.create('table.html') ?
// Place the new row on top
os.chdir(fast_dir)?
mut out := os.create('table.html')?
// place the new row on top
html_message := message.replace_each(['<', '&lt;', '>', '&gt;'])
table =
'<tr>
' <tr>
<td>$date.format()</td>
<td><a target=_blank href="https://github.com/vlang/v/commit/$commit">$commit</a></td>
<td>$html_message</td>
@ -105,26 +105,25 @@ fn main() {
<td>${int(f64(vlines) / f64(diff1) * 1000.0)}</td>
</tr>\n' +
table.trim_space()
out.writeln(table) ?
out.writeln(table)?
out.close()
// Regenerate index.html
header := os.read_file('header.html') ?
footer := os.read_file('footer.html') ?
mut res := os.create('index.html') ?
res.writeln(header) ?
res.writeln(table) ?
res.writeln(footer) ?
// regenerate index.html
header := os.read_file('header.html')?
footer := os.read_file('footer.html')?
mut res := os.create('index.html')?
res.writeln(header)?
res.writeln(table)?
res.writeln(footer)?
res.close()
//}
// exec('git checkout master')
// os.write_file('last_commit.txt', commits[commits.len - 1]) ?
// Upload the result to github pages
// upload the result to github pages
if os.args.contains('-upload') {
println('uploading...')
os.chdir('website') ?
os.chdir('website')?
os.execute_or_exit('git checkout gh-pages')
os.cp('../index.html', 'index.html') ?
os.rm('../index.html') ?
os.cp('../index.html', 'index.html')?
os.rm('../index.html')?
os.system('git commit -am "update benchmark"')
os.system('git push origin gh-pages')
}
@ -135,7 +134,7 @@ fn exec(s string) string {
return e.output.trim_right('\r\n')
}
// returns milliseconds
// measure returns milliseconds
fn measure(cmd string, description string) int {
println(' Measuring $description')
println(' Warming up...')
@ -187,7 +186,7 @@ fn measure_steps(vdir string) (int, int, int, int, int) {
cgen = line[0].int()
}
} else {
// Fetch number of V lines
// fetch number of V lines
if line[0].contains('V') && line[0].contains('source') && line[0].contains('size') {
start := line[0].index(':') or { 0 }
end := line[0].index('lines,') or { 0 }

View File

@ -10,9 +10,9 @@ fn generate_strings(str_len int, arr_len int) []string {
}
fn fuzz1() {
amount := 200000 - rand.intn(100000)
amount2 := 200000 - rand.intn(100000)
len := 25 - rand.intn(10)
amount := 200000 - rand.intn(100000) or { 0 }
amount2 := 200000 - rand.intn(100000) or { 0 }
len := 25 - rand.intn(10) or { 0 }
arr := generate_strings(len, amount)
arr2 := generate_strings(len, amount2)
mut m := map[string]int{}
@ -34,8 +34,8 @@ fn fuzz1() {
fn fuzz2() {
mut m := map[string]int{}
amount := rand.intn(500000) + 1
len := 25 - rand.intn(10)
amount := rand.intn(500000) or { 0 } + 1
len := 25 - rand.intn(10) or { 0 }
arr := generate_strings(len, amount)
for i, x in arr {
m[x] = i
@ -54,8 +54,8 @@ fn fuzz2() {
fn fuzz3() {
mut m := map[string]int{}
amount := rand.intn(500000) + 1
len := 25 - rand.intn(10)
amount := rand.intn(500000) or { 0 } + 1
len := 25 - rand.intn(10) or { 0 }
arr := generate_strings(len, amount)
for i, x in arr {
if (i % 10000) == 0 {
@ -74,8 +74,8 @@ fn fuzz3() {
}
fn fuzz4() {
amount := rand.intn(500000)
len := 25 - rand.intn(10)
amount := rand.intn(500000) or { 0 }
len := 25 - rand.intn(10) or { 0 }
arr := generate_strings(len, amount)
mut m := map[string]int{}
for i in 0 .. amount {
@ -93,7 +93,7 @@ fn fuzz4() {
}
fn fuzz5() {
amount := rand.intn(500000) + 1
amount := rand.intn(500000) or { 0 } + 1
arr := generate_strings(20, amount)
mut m := map[string]int{}
for i in 0 .. amount {
@ -114,8 +114,8 @@ fn fuzz5() {
fn fuzz6() {
mut m := map[string]int{}
amount := rand.intn(500000) + 1
len := 25 - rand.intn(10)
amount := rand.intn(500000) or { 0 } + 1
len := 25 - rand.intn(10) or { 0 }
arr := generate_strings(len, amount)
for i, x in arr {
m[x]++

View File

@ -0,0 +1,67 @@
import os
import time
import v.ast
import v.pref
import v.parser
import v.errors
import v.scanner
fn main() {
files := os.args#[1..]
if files.len > 0 && files[0].starts_with('@') {
lst_path := files[0].all_after('@')
listed_files := os.read_file(lst_path)?.split('\n')
process_files(listed_files)?
return
}
process_files(files)?
}
fn process_files(files []string) ? {
mut table := ast.new_table()
mut pref := pref.new_preferences()
pref.is_fmt = true
pref.skip_warnings = true
pref.output_mode = .silent
mut sw := time.new_stopwatch()
mut total_us := i64(0)
mut total_bytes := i64(0)
mut total_tokens := i64(0)
for f in files {
if f == '' {
continue
}
if f.ends_with('_test.v') {
continue
}
// do not measure the scanning, but only the parsing:
mut p := new_parser(f, .skip_comments, table, pref)
///
sw.restart()
_ := p.parse()
f_us := sw.elapsed().microseconds()
///
total_us += f_us
total_bytes += p.scanner.text.len
total_tokens += p.scanner.all_tokens.len
println('${f_us:10}us ${p.scanner.all_tokens.len:10} ${p.scanner.text.len:10} ${(f64(p.scanner.text.len) / p.scanner.all_tokens.len):7.3} ${p.errors.len:4} $f')
}
println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${(f64(total_tokens) / total_bytes):7.3} | speed: ${(f64(total_bytes) / total_us):2.5f} MB/s')
}
fn new_parser(path string, comments_mode scanner.CommentsMode, table &ast.Table, pref &pref.Preferences) &parser.Parser {
mut p := &parser.Parser{
scanner: scanner.new_scanner_file(path, comments_mode, pref) or { panic(err) }
comments_mode: comments_mode
table: table
pref: pref
scope: &ast.Scope{
start_pos: 0
parent: table.global_scope
}
errors: []errors.Error{}
warnings: []errors.Warning{}
}
p.set_path(path)
return p
}

View File

@ -0,0 +1,42 @@
import os
import time
import v.scanner
import v.pref
fn main() {
files := os.args#[1..]
if files.len > 0 && files[0].starts_with('@') {
lst_path := files[0].all_after('@')
listed_files := os.read_file(lst_path)?.split('\n')
process_files(listed_files)?
return
}
process_files(files)?
}
fn process_files(files []string) ? {
mut pref := pref.new_preferences()
pref.is_fmt = true
pref.skip_warnings = true
pref.output_mode = .silent
mut sw := time.new_stopwatch()
mut total_us := i64(0)
mut total_bytes := i64(0)
mut total_tokens := i64(0)
for f in files {
if f == '' {
continue
}
if f.ends_with('_test.v') {
continue
}
sw.restart()
s := scanner.new_scanner_file(f, .skip_comments, pref)?
f_us := sw.elapsed().microseconds()
total_us += f_us
total_bytes += s.text.len
total_tokens += s.all_tokens.len
println('${f_us:10}us ${s.all_tokens.len:10} ${s.text.len:10} ${(f64(s.text.len) / s.all_tokens.len):7.3f} $f')
}
println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${(f64(total_tokens) / total_bytes):7.3f} | speed: ${(f64(total_bytes) / total_us):2.5f} MB/s')
}

View File

@ -1,141 +0,0 @@
// Copyright (c) 2020 Lars Pontoppidan. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
import os
import flag
const (
tool_name = os.file_name(os.executable())
tool_version = '0.0.2'
tool_description = 'Prints all V functions in .v files under PATH/, that do not yet have documentation comments.'
)
struct UndocumentedFN {
line int
signature string
tags []string
}
struct Options {
show_help bool
collect_tags bool
deprecated bool
}
fn collect(path string, mut l []string, f fn (string, mut []string)) {
if !os.is_dir(path) {
return
}
mut files := os.ls(path) or { return }
for file in files {
p := path + os.path_separator + file
if os.is_dir(p) && !os.is_link(p) {
collect(p, mut l, f)
} else if os.exists(p) {
f(p, mut l)
}
}
return
}
fn report_undocumented_functions_in_path(opt Options, path string) {
mut files := []string{}
collect_fn := fn (path string, mut l []string) {
if os.file_ext(path) == '.v' {
l << os.real_path(path)
}
}
collect(path, mut files, collect_fn)
for file in files {
if file.ends_with('_test.v') {
continue
}
report_undocumented_functions_in_file(opt, file)
}
}
fn report_undocumented_functions_in_file(opt Options, file string) {
contents := os.read_file(file) or { panic(err) }
lines := contents.split('\n')
mut info := []UndocumentedFN{}
for i, line in lines {
if line.starts_with('pub fn') || (line.starts_with('fn ') && !(line.starts_with('fn C.')
|| line.starts_with('fn main'))) {
// println('Match: $line')
if i > 0 && lines.len > 0 {
mut line_above := lines[i - 1]
if !line_above.starts_with('//') {
mut tags := []string{}
mut grab := true
for j := i - 1; j >= 0; j-- {
prev_line := lines[j]
if prev_line.contains('}') { // We've looked back to the above scope, stop here
break
} else if prev_line.starts_with('[') {
tags << collect_tags(prev_line)
continue
} else if prev_line.starts_with('//') { // Single-line comment
grab = false
break
}
}
if grab {
clean_line := line.all_before_last(' {')
info << UndocumentedFN{i + 1, clean_line, tags}
}
}
}
}
}
if info.len > 0 {
for undocumented_fn in info {
tags_str := if opt.collect_tags && undocumented_fn.tags.len > 0 {
'$undocumented_fn.tags'
} else {
''
}
if opt.deprecated {
println('$file:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
} else {
if 'deprecated' !in undocumented_fn.tags {
println('$file:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
}
}
}
}
}
fn collect_tags(line string) []string {
mut cleaned := line.all_before('/')
cleaned = cleaned.replace_each(['[', '', ']', '', ' ', ''])
return cleaned.split(',')
}
fn main() {
if os.args.len == 1 {
println('Usage: $tool_name PATH \n$tool_description\n$tool_name -h for more help...')
exit(1)
}
mut fp := flag.new_flag_parser(os.args[1..])
fp.application(tool_name)
fp.version(tool_version)
fp.description(tool_description)
fp.arguments_description('PATH [PATH]...')
// Collect tool options
opt := Options{
show_help: fp.bool('help', `h`, false, 'Show this help text.')
deprecated: fp.bool('deprecated', `d`, false, 'Include deprecated functions in output.')
collect_tags: fp.bool('tags', `t`, false, 'Also print function tags if any is found.')
}
if opt.show_help {
println(fp.usage())
exit(0)
}
for path in os.args[1..] {
if os.is_file(path) {
report_undocumented_functions_in_file(opt, path)
} else {
report_undocumented_functions_in_path(opt, path)
}
}
}

View File

@ -24,6 +24,7 @@ pub fn cprint(omessage string) {
message = term.cyan(message)
}
print(message)
flush_stdout()
}
pub fn cprint_strong(omessage string) {
@ -32,16 +33,19 @@ pub fn cprint_strong(omessage string) {
message = term.bright_green(message)
}
print(message)
flush_stdout()
}
pub fn cprintln(omessage string) {
cprint(omessage)
println('')
flush_stdout()
}
pub fn cprintln_strong(omessage string) {
cprint_strong(omessage)
println('')
flush_stdout()
}
pub fn verbose_trace(label string, message string) {

View File

@ -19,6 +19,8 @@ pub const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
pub const fail_fast = os.getenv('VTEST_FAIL_FAST') == '1'
pub const fail_flaky = os.getenv('VTEST_FAIL_FLAKY') == '1'
pub const test_only = os.getenv('VTEST_ONLY').split_any(',')
pub const test_only_fn = os.getenv('VTEST_ONLY_FN').split_any(',')
@ -35,7 +37,6 @@ pub mut:
vroot string
vtmp_dir string
vargs string
failed bool
fail_fast bool
benchmark benchmark.Benchmark
rm_binaries bool = true
@ -122,6 +123,7 @@ pub fn (mut ts TestSession) print_messages() {
// progress mode, the last line is rewritten many times:
if is_ok && !ts.silent_mode {
print('\r$empty\r$msg')
flush_stdout()
} else {
// the last \n is needed, so SKIP/FAIL messages
// will not get overwritten by the OK ones
@ -157,6 +159,7 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
$if windows {
skip_files << 'examples/database/mysql.v'
skip_files << 'examples/database/orm.v'
skip_files << 'examples/smtp/mail.v' // requires OpenSSL
skip_files << 'examples/websocket/ping.v' // requires OpenSSL
skip_files << 'examples/websocket/client-server/client.v' // requires OpenSSL
skip_files << 'examples/websocket/client-server/server.v' // requires OpenSSL
@ -164,6 +167,14 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
skip_files << 'examples/database/orm.v' // try fix it
}
}
$if windows {
// TODO: remove when closures on windows are supported
skip_files << 'examples/pendulum-simulation/animation.v'
skip_files << 'examples/pendulum-simulation/full.v'
skip_files << 'examples/pendulum-simulation/parallel.v'
skip_files << 'examples/pendulum-simulation/parallel_with_iw.v'
skip_files << 'examples/pendulum-simulation/sequential.v'
}
if testing.github_job != 'sokol-shaders-can-be-compiled' {
// These examples need .h files that are produced from the supplied .glsl files,
// using by the shader compiler tools in https://github.com/floooh/sokol-tools-bin/archive/pre-feb2021-api-changes.tar.gz
@ -277,7 +288,7 @@ pub fn (mut ts TestSession) test() {
fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
mut ts := &TestSession(p.get_shared_context())
if ts.fail_fast {
if ts.failed {
if ts.failed_cmds.len > 0 {
return pool.no_result
}
}
@ -297,12 +308,14 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
mut run_js := false
is_fmt := ts.vargs.contains('fmt')
is_vet := ts.vargs.contains('vet')
produces_file_output := !(is_fmt || is_vet)
if relative_file.ends_with('js.v') {
if !is_fmt {
if produces_file_output {
cmd_options << ' -b js'
run_js = true
}
run_js = true
}
if relative_file.contains('global') && !is_fmt {
@ -324,13 +337,13 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
fname.replace('.v', '')
}
generated_binary_fpath := os.join_path_single(tmpd, generated_binary_fname)
if os.exists(generated_binary_fpath) {
if ts.rm_binaries {
os.rm(generated_binary_fpath) or {}
if produces_file_output {
if os.exists(generated_binary_fpath) {
if ts.rm_binaries {
os.rm(generated_binary_fpath) or {}
}
}
}
if !ts.vargs.contains('fmt') {
cmd_options << ' -o ${os.quoted_path(generated_binary_fpath)}'
}
cmd := '${os.quoted_path(ts.vexe)} ' + cmd_options.join(' ') + ' ${os.quoted_path(file)}'
@ -351,7 +364,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
details := get_test_details(file)
os.setenv('VTEST_RETRY_MAX', '$details.retry', true)
for retry := 1; retry <= details.retry; retry++ {
ts.append_message(.info, ' retrying $retry/$details.retry of $relative_file ...')
ts.append_message(.info, ' [stats] retrying $retry/$details.retry of $relative_file ; known flaky: $details.flaky ...')
os.setenv('VTEST_RETRY', '$retry', true)
status = os.system(cmd)
if status == 0 {
@ -361,7 +374,12 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
time.sleep(500 * time.millisecond)
}
ts.failed = true
if details.flaky && !testing.fail_flaky {
ts.append_message(.info, ' *FAILURE* of the known flaky test file $relative_file is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: $details.retry .')
unsafe {
goto test_passed_system
}
}
ts.benchmark.fail()
tls_bench.fail()
ts.add_failed_cmd(cmd)
@ -377,7 +395,6 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
mut r := os.execute(cmd)
if r.exit_code < 0 {
ts.failed = true
ts.benchmark.fail()
tls_bench.fail()
ts.append_message(.fail, tls_bench.step_message_fail(normalised_relative_file))
@ -388,7 +405,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
details := get_test_details(file)
os.setenv('VTEST_RETRY_MAX', '$details.retry', true)
for retry := 1; retry <= details.retry; retry++ {
ts.append_message(.info, ' retrying $retry/$details.retry of $relative_file ...')
ts.append_message(.info, ' retrying $retry/$details.retry of $relative_file ; known flaky: $details.flaky ...')
os.setenv('VTEST_RETRY', '$retry', true)
r = os.execute(cmd)
if r.exit_code == 0 {
@ -397,7 +414,12 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
}
}
ts.failed = true
if details.flaky && !testing.fail_flaky {
ts.append_message(.info, ' *FAILURE* of the known flaky test file $relative_file is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: $details.retry .')
unsafe {
goto test_passed_execute
}
}
ts.benchmark.fail()
tls_bench.fail()
ending_newline := if r.output.ends_with('\n') { '\n' } else { '' }
@ -412,10 +434,8 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
}
}
if os.exists(generated_binary_fpath) {
if ts.rm_binaries {
os.rm(generated_binary_fpath) or {}
}
if produces_file_output && os.exists(generated_binary_fpath) && ts.rm_binaries {
os.rm(generated_binary_fpath) or {}
}
return pool.no_result
}
@ -443,12 +463,12 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
mut skipped := oskipped.clone()
next_file: for f in files {
fnormalised := f.replace('\\', '/')
// NB: a `testdata` folder, is the preferred name of a folder, containing V code,
// Note: a `testdata` folder, is the preferred name of a folder, containing V code,
// that you *do not want* the test framework to find incidentally for various reasons,
// for example module import tests, or subtests, that are compiled/run by other parent tests
// in specific configurations, etc.
if fnormalised.contains('testdata/') || fnormalised.contains('modules/')
|| f.contains('preludes/') {
|| fnormalised.contains('preludes/') {
continue
}
$if windows {
@ -466,7 +486,8 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
skipped << skipped_f
}
for skip_prefix in oskipped {
if f.starts_with(skip_prefix) {
skip_folder := skip_prefix + '/'
if fnormalised.starts_with(skip_folder) {
continue next_file
}
}
@ -486,7 +507,7 @@ pub fn v_build_failing_skipped(zargs string, folder string, oskipped []string, c
cb(mut session)
session.test()
eprintln(session.benchmark.total_message(finish_label))
return session.failed
return session.failed_cmds.len > 0
}
pub fn build_v_cmd_failed(cmd string) bool {
@ -540,6 +561,7 @@ pub fn eheader(msg string) {
pub fn header(msg string) {
println(term.header_left(msg, '-'))
flush_stdout()
}
pub fn setup_new_vtmp_folder() string {
@ -553,6 +575,7 @@ pub fn setup_new_vtmp_folder() string {
pub struct TestDetails {
pub mut:
retry int
flaky bool // when flaky tests fail, the whole run is still considered successfull, unless VTEST_FAIL_FLAKY is 1
}
pub fn get_test_details(file string) TestDetails {
@ -562,6 +585,9 @@ pub fn get_test_details(file string) TestDetails {
if line.starts_with('// vtest retry:') {
res.retry = line.all_after(':').trim_space().int()
}
if line.starts_with('// vtest flaky:') {
res.flaky = line.all_after(':').trim_space().bool()
}
}
return res
}

View File

@ -75,7 +75,7 @@ pub fn prepare_vc_source(vcdir string, cdir string, commit string) (string, stri
}
pub fn clone_or_pull(remote_git_url string, local_worktree_path string) {
// NB: after clone_or_pull, the current repo branch is === HEAD === master
// Note: after clone_or_pull, the current repo branch is === HEAD === master
if os.is_dir(local_worktree_path) && os.is_dir(os.join_path_single(local_worktree_path, '.git')) {
// Already existing ... Just pulling in this case is faster usually.
scripting.run('git -C "$local_worktree_path" checkout --quiet master')

View File

@ -16,7 +16,7 @@ const (
| git checkout known_good_commit
| git bisect good
| ## Now git will automatically checkout a middle commit between the bad and the good
| cmd/tools/oldv HEAD --command="run commands in oldv folder, to verify if the commit is good or bad"
| cmd/tools/oldv --bisect --command="run commands in oldv folder, to verify if the commit is good or bad"
| ## See what the result is, and either do: ...
| git bisect good
| ## ... or do:
@ -40,6 +40,7 @@ mut:
cleanup bool // should the tool run a cleanup first
use_cache bool // use local cached copies for --vrepo and --vcrepo in
fresh_tcc bool // do use `make fresh_tcc`
is_bisect bool // bisect mode; usage: `cmd/tools/oldv -b -c './v run bug.v'`
}
fn (mut c Context) compile_oldv_if_needed() {
@ -56,7 +57,7 @@ fn (mut c Context) compile_oldv_if_needed() {
c.vgcontext.compile_oldv_if_needed()
c.commit_v_hash = c.vgcontext.commit_v__hash
if !os.exists(c.vgcontext.vexepath) && c.cmd_to_run.len > 0 {
// NB: 125 is a special code, that git bisect understands as 'skip this commit'.
// Note: 125 is a special code, that git bisect understands as 'skip this commit'.
// it is used to inform git bisect that the current commit leads to a build failure.
exit(125)
}
@ -122,8 +123,9 @@ fn main() {
context.vgo.vc_repo_url = 'https://github.com/vlang/vc'
}
should_sync := fp.bool('cache-sync', `s`, false, 'Update the local cache')
if !should_sync {
fp.limit_free_args(1, 1) ?
context.is_bisect = fp.bool('bisect', `b`, false, 'Bisect mode. Use the current commit in the repo where oldv is.')
if !should_sync && !context.is_bisect {
fp.limit_free_args(1, 1)?
}
////
context.cleanup = fp.bool('clean', 0, false, 'Clean before running (slower).')
@ -141,6 +143,10 @@ fn main() {
}
if commits.len > 0 {
context.commit_v = commits[0]
if context.is_bisect {
eprintln('In bisect mode, you should not pass any commits, since oldv will use the current one.')
exit(2)
}
} else {
context.commit_v = scripting.run('git rev-list -n1 HEAD')
}

View File

@ -194,7 +194,7 @@ fn main() {
fp.description(tool_description)
fp.arguments_description('COMMIT_BEFORE [COMMIT_AFTER]')
fp.skip_executable()
fp.limit_free_args(1, 2) ?
fp.limit_free_args(1, 2)?
context.vflags = fp.string('vflags', 0, '', 'Additional options to pass to the v commands, for example "-cc tcc"')
context.hyperfineopts = fp.string('hyperfine_options', 0, '', 'Additional options passed to hyperfine.
${flag.space}For example on linux, you may want to pass:

View File

@ -0,0 +1,79 @@
import os
import term
import flag
const tools_folder = os.real_path(os.dir(os.executable()))
const oldvexe = fullpath(tools_folder, 'oldv')
const oldv_source = fullpath(tools_folder, 'oldv.v')
const vroot = os.real_path(os.dir(os.dir(tools_folder)))
const vexe = fullpath(vroot, 'v')
fn fullpath(folder string, fname string) string {
return os.real_path(os.join_path_single(folder, exename(fname)))
}
fn exename(n string) string {
if n.ends_with('.v') || os.user_os() != 'windows' {
return n
}
return '${n}.exe'
}
struct Context {
mut:
old_commit string
new_commit string
command string
}
fn main() {
mut fp := flag.new_flag_parser(os.args)
mut context := Context{}
fp.application(os.file_name(os.executable()))
fp.version('0.0.2')
fp.description('\n Find at what commit a regression occurred.
To find when a regression happened (regression_bug.v should fail on master):
./v run cmd/tools/regress.v --old a7019ac --command " ./v run /abs/path/to/regression_bug.v"
To find when a feature was implemented (feature.v should succeed on master):
./v run cmd/tools/regress.v --old a7019ac --command "! ./v run /abs/path/to/feature.v"')
fp.skip_executable()
//
context.new_commit = fp.string('new', `n`, 'master', 'The new commit, by default: master.')
context.old_commit = fp.string('old', `o`, '', 'A known old commit, required (for it, COMMAND should exit with 0).')
context.command = fp.string('command', `c`, '', 'A command to execute. Should exit with 0 for the *old* commits.')
fp.finalize() or {}
if context.old_commit == '' {
eprintln('--old COMMIT is required')
exit(1)
}
if context.command == '' {
eprintln('--command "COMMAND" is required')
exit(2)
}
if !os.exists(oldvexe) {
if 0 != execute('${os.quoted_path(vexe)} -o ${os.quoted_path(oldvexe)} ${os.quoted_path(oldv_source)}') {
panic('can not compile $oldvexe')
}
}
os.execute('git checkout master')
os.execute('git bisect reset')
os.execute('git checkout $context.new_commit')
os.execute('git bisect start')
os.execute('git bisect new')
os.execute('git checkout $context.old_commit')
os.execute('git bisect old')
println(term.colorize(term.bright_yellow, term.header('', '-')))
execute('git bisect run ${os.quoted_path(oldvexe)} --bisect -c "$context.command"')
println(term.colorize(term.bright_yellow, term.header('', '-')))
os.execute('git bisect reset')
os.execute('git checkout master')
}
fn execute(cmd string) int {
eprintln('### $cmd')
return os.system(cmd)
}

View File

@ -143,7 +143,7 @@ const (
fn main() {
mut context := Context{}
context.parse_options() ?
context.parse_options()?
context.run()
context.show_diff_summary()
}
@ -152,16 +152,16 @@ fn (mut context Context) parse_options() ? {
mut fp := flag.new_flag_parser(os.args)
fp.application(os.file_name(os.executable()))
fp.version('0.0.1')
fp.description('Repeat command(s) and collect statistics. NB: you have to quote each command, if it contains spaces.')
fp.description('Repeat command(s) and collect statistics. Note: you have to quote each command, if it contains spaces.')
fp.arguments_description('CMD1 CMD2 ...')
fp.skip_executable()
fp.limit_free_args_to_at_least(1) ?
fp.limit_free_args_to_at_least(1)?
context.count = fp.int('count', `c`, 10, 'Repetition count.')
context.series = fp.int('series', `s`, 2, 'Series count. `-s 2 -c 4 a b` => aaaabbbbaaaabbbb, while `-s 3 -c 2 a b` => aabbaabbaabb.')
context.warmup = fp.int('warmup', `w`, 2, 'Warmup runs. These are done *only at the start*, and are ignored.')
context.show_help = fp.bool('help', `h`, false, 'Show this help screen.')
context.use_newline = fp.bool('newline', `n`, false, 'Use \\n, do not overwrite the last line. Produces more output, but easier to diagnose.')
context.show_output = fp.bool('output', `O`, false, 'Show command stdout/stderr in the progress indicator for each command. NB: slower, for verbose commands.')
context.show_output = fp.bool('output', `O`, false, 'Show command stdout/stderr in the progress indicator for each command. Note: slower, for verbose commands.')
context.verbose = fp.bool('verbose', `v`, false, 'Be more verbose.')
context.fail_on_maxtime = fp.int('max_time', `m`, max_time, 'Fail with exit code 2, when first cmd takes above M milliseconds (regression).')
context.fail_on_regress_percent = fp.int('fail_percent', `f`, max_fail_percent, 'Fail with exit code 3, when first cmd is X% slower than the rest (regression).')
@ -200,8 +200,13 @@ fn (mut context Context) parse_options() ? {
}
}
fn flushed_print(s string) {
print(s)
flush_stdout()
}
fn (mut context Context) clear_line() {
print(context.cline)
flushed_print(context.cline)
}
fn (mut context Context) expand_all_commands(commands []string) []string {
@ -247,7 +252,7 @@ fn (mut context Context) run() {
println('Series: ${si:4}/${context.series:-4}, command: $cmd')
if context.warmup > 0 && run_warmups < context.commands.len {
for i in 1 .. context.warmup + 1 {
print('${context.cgoback}warming up run: ${i:4}/${context.warmup:-4} for ${cmd:-50s} took ${duration:6} ms ...')
flushed_print('${context.cgoback}warming up run: ${i:4}/${context.warmup:-4} for ${cmd:-50s} took ${duration:6} ms ...')
mut sw := time.new_stopwatch()
res := os.execute(cmd)
if res.exit_code != 0 {
@ -260,9 +265,9 @@ fn (mut context Context) run() {
context.clear_line()
for i in 1 .. (context.count + 1) {
avg := f64(sum) / f64(i)
print('${context.cgoback}Average: ${avg:9.3f}ms | run: ${i:4}/${context.count:-4} | took ${duration:6} ms')
flushed_print('${context.cgoback}Average: ${avg:9.3f}ms | run: ${i:4}/${context.count:-4} | took ${duration:6} ms')
if context.show_output {
print(' | result: ${oldres:s}')
flushed_print(' | result: ${oldres:s}')
}
mut sw := time.new_stopwatch()
res := scripting.exec(cmd) or { continue }
@ -288,7 +293,7 @@ fn (mut context Context) run() {
context.results[icmd].atiming = new_aints(context.results[icmd].timings, context.nmins,
context.nmaxs)
context.clear_line()
print(context.cgoback)
flushed_print(context.cgoback)
mut m := map[string][]int{}
ioutputs := context.results[icmd].outputs
for o in ioutputs {
@ -358,7 +363,7 @@ fn (mut context Context) show_diff_summary() {
println('context: $context')
}
if int(base) > context.fail_on_maxtime {
print(performance_regression_label)
flushed_print(performance_regression_label)
println('average time: ${base:6.1f} ms > $context.fail_on_maxtime ms threshold.')
exit(2)
}
@ -367,7 +372,7 @@ fn (mut context Context) show_diff_summary() {
}
fail_threshold_max := f64(context.fail_on_regress_percent)
if first_cmd_percentage > fail_threshold_max {
print(performance_regression_label)
flushed_print(performance_regression_label)
println('${first_cmd_percentage:5.1f}% > ${fail_threshold_max:5.1f}% threshold.')
exit(3)
}

View File

@ -42,7 +42,7 @@ fn cleanup_tdir() {
fn create_test(tname string, tcontent string) ?string {
tpath := os.join_path(tdir, tname)
os.write_file(tpath, tcontent) ?
os.write_file(tpath, tcontent)?
eprintln('>>>>>>>> tpath: $tpath | tcontent: $tcontent')
return tpath
}
@ -52,17 +52,17 @@ fn main() {
os.chdir(os.wd_at_startup) or {}
}
println('> vroot: $vroot | vexe: $vexe | tdir: $tdir')
ok_fpath := create_test('a_single_ok_test.v', 'fn test_ok(){ assert true }') ?
ok_fpath := create_test('a_single_ok_test.v', 'fn test_ok(){ assert true }')?
check_ok('"$vexe" "$ok_fpath"')
check_ok('"$vexe" test "$ok_fpath"')
check_ok('"$vexe" test "$tdir"')
fail_fpath := create_test('a_single_failing_test.v', 'fn test_fail(){ assert 1 == 2 }') ?
fail_fpath := create_test('a_single_failing_test.v', 'fn test_fail(){ assert 1 == 2 }')?
check_fail('"$vexe" "$fail_fpath"')
check_fail('"$vexe" test "$fail_fpath"')
check_fail('"$vexe" test "$tdir"')
rel_dir := os.join_path(tdir, rand.ulid())
os.mkdir(rel_dir) ?
os.chdir(rel_dir) ?
os.mkdir(rel_dir)?
os.chdir(rel_dir)?
check_ok('"$vexe" test "..${os.path_separator + os.base(ok_fpath)}"')
println('> all done')
}

View File

@ -0,0 +1,50 @@
// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license that can be found in the LICENSE file.
module main
import os
import v.util
const vexe = os.getenv('VEXE')
fn main() {
vmodules := os.vmodules_dir()
c2v_dir := os.join_path(vmodules, 'c2v')
mut c2v_bin := os.join_path(c2v_dir, 'c2v')
$if windows {
c2v_bin += '.exe'
}
// Git clone c2v
if !os.exists(c2v_dir) {
println('C2V is not installed. Cloning C2V to $c2v_dir ...')
os.chdir(vmodules)?
res := os.execute('git clone https://github.com/vlang/c2v')
if res.exit_code != 0 {
eprintln('Failed to download C2V.')
exit(1)
}
}
// Compile c2v
if !os.exists(c2v_bin) {
os.chdir(c2v_dir)?
println('Compiling c2v ...')
res2 := os.execute('${os.quoted_path(vexe)} -o ${os.quoted_path(c2v_bin)} -keepc -g -experimental .')
if res2.exit_code != 0 {
eprintln(res2.output)
eprintln('Failed to compile C2V. This should not happen. Please report it via GitHub.')
exit(2)
}
}
if os.args.len < 3 {
eprintln('Wrong number of arguments. Use `v translate file.c` .')
exit(3)
}
passed_args := util.args_quote_paths(os.args[2..])
// println(passed_args)
os.chdir(os.wd_at_startup)?
res := os.system('$c2v_bin $passed_args')
if res != 0 {
eprintln('C2V failed to translate the C files. Please report it via GitHub.')
exit(4)
}
}

View File

@ -24,7 +24,7 @@ fn C.cJSON_CreateNull() &C.cJSON
// fn C.cJSON_CreateNumber() &C.cJSON
// fn C.cJSON_CreateString() &C.cJSON
fn C.cJSON_CreateRaw(&byte) &C.cJSON
fn C.cJSON_CreateRaw(&u8) &C.cJSON
fn C.cJSON_IsInvalid(voidptr) bool
@ -45,13 +45,13 @@ fn C.cJSON_IsObject(voidptr) bool
fn C.cJSON_IsRaw(voidptr) bool
fn C.cJSON_AddItemToObject(voidptr, &byte, voidptr)
fn C.cJSON_AddItemToObject(voidptr, &u8, voidptr)
fn C.cJSON_AddItemToArray(voidptr, voidptr)
fn C.cJSON_Delete(voidptr)
fn C.cJSON_Print(voidptr) &byte
fn C.cJSON_Print(voidptr) &u8
[inline]
fn create_object() &C.cJSON {

View File

@ -44,7 +44,7 @@ fn main() {
for hf in hfields.split(',') {
ctx.hide_names[hf] = true
}
fp.limit_free_args_to_at_least(1) ?
fp.limit_free_args_to_at_least(1)?
rest_of_args := fp.remaining_parameters()
for vfile in rest_of_args {
file := get_abs_path(vfile)
@ -283,7 +283,7 @@ fn (t Tree) embed_file(node ast.EmbeddedFile) &Node {
obj.add('compression_type', t.string_node(node.compression_type))
obj.add('is_compressed', t.bool_node(node.is_compressed))
obj.add('len', t.number_node(node.len))
obj.add('bytes', t.array_node_byte(node.bytes))
obj.add('bytes', t.array_node_u8(node.bytes))
return obj
}
@ -674,8 +674,8 @@ fn (t Tree) interface_decl(node ast.InterfaceDecl) &Node {
obj.add('name_pos', t.pos(node.name_pos))
obj.add_terse('language', t.enum_node(node.language))
obj.add('pos', t.pos(node.pos))
obj.add('are_ifaces_expanded', t.bool_node(node.are_ifaces_expanded))
obj.add_terse('ifaces', t.array_node_interface_embedding(node.ifaces))
obj.add('are_embeds_expanded', t.bool_node(node.are_embeds_expanded))
obj.add_terse('embeds', t.array_node_interface_embedding(node.embeds))
obj.add_terse('attrs', t.array_node_attr(node.attrs))
return obj
}
@ -1216,7 +1216,7 @@ fn (t Tree) string_inter_literal(node ast.StringInterLiteral) &Node {
obj.add_terse('pluss', t.array_node_bool(node.pluss))
obj.add_terse('fills', t.array_node_bool(node.fills))
obj.add_terse('fmt_poss', t.array_node_position(node.fmt_poss))
obj.add_terse('fmts', t.array_node_byte(node.fmts))
obj.add_terse('fmts', t.array_node_u8(node.fmts))
obj.add_terse('need_fmts', t.array_node_bool(node.need_fmts))
obj.add('pos', t.pos(node.pos))
return obj
@ -1358,6 +1358,7 @@ fn (t Tree) postfix_expr(node ast.PostfixExpr) &Node {
obj.add_terse('expr', t.expr(node.expr))
obj.add('auto_locked', t.string_node(node.auto_locked))
obj.add('pos', t.pos(node.pos))
obj.add('is_c2v_prefix', t.bool_node(node.is_c2v_prefix))
return obj
}
@ -2209,7 +2210,7 @@ fn (t Tree) array_node_int(nodes []int) &Node {
return arr
}
fn (t Tree) array_node_byte(nodes []byte) &Node {
fn (t Tree) array_node_u8(nodes []u8) &Node {
mut arr := new_array()
for node in nodes {
arr.add_item(t.number_node(node))

View File

@ -46,12 +46,12 @@ fn (context Context) footer() string {
return ')\n'
}
fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
fn (context Context) file2v(bname string, fbytes []u8, bn_max int) string {
mut sb := strings.new_builder(1000)
bn_diff_len := bn_max - bname.len
sb.write_string('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = $fbytes.len\n')
fbyte := fbytes[0]
bnmae_line := '\t$bname' + ' '.repeat(bn_diff_len) + ' = [byte($fbyte), '
bnmae_line := '\t$bname' + ' '.repeat(bn_diff_len) + ' = [u8($fbyte), '
sb.write_string(bnmae_line)
mut line_len := bnmae_line.len + 3
for i := 1; i < fbytes.len; i++ {
@ -73,11 +73,11 @@ fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
return sb.str()
}
fn (context Context) bname_and_bytes(file string) ?(string, []byte) {
fn (context Context) bname_and_bytes(file string) ?(string, []u8) {
fname := os.file_name(file)
fname_escaped := fname.replace_each(['.', '_', '-', '_'])
byte_name := '$context.prefix$fname_escaped'.to_lower()
fbytes := os.read_bytes(file) or { return error('Error: $err.msg') }
fbytes := os.read_bytes(file) or { return error('Error: $err.msg()') }
return byte_name, fbytes
}
@ -108,7 +108,7 @@ fn main() {
exit(0)
}
files := fp.finalize() or {
eprintln('Error: $err.msg')
eprintln('Error: $err.msg()')
exit(1)
}
real_files := files.filter(it != 'bin2v')
@ -120,22 +120,22 @@ fn main() {
if context.write_file != '' && os.file_ext(context.write_file) !in ['.vv', '.v'] {
context.write_file += '.v'
}
mut file_byte_map := map[string][]byte{}
mut file_byte_map := map[string][]u8{}
for file in real_files {
bname, fbytes := context.bname_and_bytes(file) or {
eprintln(err.msg)
eprintln(err.msg())
exit(1)
}
file_byte_map[bname] = fbytes
}
max_bname := context.max_bname_len(file_byte_map.keys())
if context.write_file.len > 0 {
mut out_file := os.create(context.write_file) ?
out_file.write_string(context.header()) ?
mut out_file := os.create(context.write_file)?
out_file.write_string(context.header())?
for bname, fbytes in file_byte_map {
out_file.write_string(context.file2v(bname, fbytes, max_bname)) ?
out_file.write_string(context.file2v(bname, fbytes, max_bname))?
}
out_file.write_string(context.footer()) ?
out_file.write_string(context.footer())?
} else {
print(context.header())
for bname, fbytes in file_byte_map {

View File

@ -118,7 +118,7 @@ fn main() {
build_output := get_v_build_output(is_verbose, is_yes, file_path)
// ask the user if he wants to submit even after an error
if !is_yes && (vdoctor_output == '' || file_content == '' || build_output == '') {
confirm_or_exit('An error occured retrieving the information, do you want to continue?')
confirm_or_exit('An error occurred retrieving the information, do you want to continue?')
}
expected_result := readline.read_line('What did you expect to see? ') or {

View File

@ -12,7 +12,8 @@ const efolders = [
fn main() {
args_string := os.args[1..].join(' ')
params := args_string.all_before('build-examples')
skip_prefixes := efolders.map(os.real_path(os.join_path_single(vroot, it)))
skip_prefixes := efolders.map(os.real_path(os.join_path_single(vroot, it)).replace('\\',
'/'))
res := testing.v_build_failing_skipped(params, 'examples', skip_prefixes, fn (mut session testing.TestSession) {
for x in efolders {
pathsegments := x.split_any('/')

View File

@ -4,7 +4,7 @@ import os
import testing
import v.util
// NB: tools like vdoc are compiled in their own subfolder
// Note: tools like vdoc are compiled in their own subfolder
// => cmd/tools/vdoc/vdoc.exe
// Usually, they have several top level .v files in the subfolder,
// that cannot be compiled separately, but instead, the whole folder,
@ -23,7 +23,7 @@ fn main() {
args_string := os.args[1..].join(' ')
vexe := os.getenv('VEXE')
vroot := os.dir(vexe)
os.chdir(vroot) ?
os.chdir(vroot)?
folder := os.join_path('cmd', 'tools')
tfolder := os.join_path(vroot, 'cmd', 'tools')
main_label := 'Building $folder ...'
@ -31,7 +31,7 @@ fn main() {
//
mut skips := []string{}
for stool in tools_in_subfolders {
skips << os.join_path(tfolder, stool)
skips << os.join_path(tfolder, stool).replace('\\', '/')
}
buildopts := args_string.all_before('build-tools')
mut session := testing.prepare_test_session(buildopts, folder, skips, main_label)
@ -43,11 +43,11 @@ fn main() {
// eprintln('> session.skip_files: $session.skip_files')
session.test()
eprintln(session.benchmark.total_message(finish_label))
if session.failed {
if session.failed_cmds.len > 0 {
exit(1)
}
//
mut executables := os.ls(session.vtmp_dir) ?
mut executables := os.ls(session.vtmp_dir)?
executables.sort()
for texe in executables {
tname := texe.replace(os.file_ext(texe), '')
@ -66,8 +66,9 @@ fn main() {
}
target_path := os.join_path(tfolder, texe)
os.mv_by_cp(tpath, target_path) or {
if !err.msg.contains('vbuild-tools') && !err.msg.contains('vtest-all') {
eprintln('error while moving $tpath to $target_path: $err.msg')
emsg := err.msg()
if !emsg.contains('vbuild-tools') && !emsg.contains('vtest-all') {
eprintln('error while moving $tpath to $target_path: $emsg')
}
continue
}

View File

@ -20,7 +20,7 @@ const (
tool_version = \'1.2.1\'
version: \'0.2.42\'
VERSION = "1.23.8"
Examples:
Bump the patch version in v.mod if it exists
v bump --patch

View File

@ -68,21 +68,21 @@ fn run_individual_test(case BumpTestCase) ? {
test_file := os.join_path_single(temp_dir, case.file_name)
os.rm(test_file) or {}
os.write_file(test_file, case.contents) ?
os.write_file(test_file, case.contents)?
//
os.execute_or_exit('${os.quoted_path(vexe)} bump --patch ${os.quoted_path(test_file)}')
patch_lines := os.read_lines(test_file) ?
patch_lines := os.read_lines(test_file)?
assert patch_lines[case.line] == case.expected_patch
os.execute_or_exit('${os.quoted_path(vexe)} bump --minor ${os.quoted_path(test_file)}')
minor_lines := os.read_lines(test_file) ?
minor_lines := os.read_lines(test_file)?
assert minor_lines[case.line] == case.expected_minor
os.execute_or_exit('${os.quoted_path(vexe)} bump --major ${os.quoted_path(test_file)}')
major_lines := os.read_lines(test_file) ?
major_lines := os.read_lines(test_file)?
assert major_lines[case.line] == case.expected_major
//
os.rm(test_file) ?
os.rm(test_file)?
}
fn test_all_bump_cases() {

View File

@ -21,6 +21,8 @@ const (
hide_warnings = '-hide-warnings' in os.args || '-w' in os.args
show_progress = os.getenv('GITHUB_JOB') == '' && '-silent' !in os.args
non_option_args = cmdline.only_non_options(os.args[2..])
is_verbose = os.getenv('VERBOSE') != ''
vcheckfolder = os.join_path_single(os.temp_dir(), 'vcheck_$os.getuid()')
)
struct CheckResult {
@ -56,6 +58,10 @@ fn main() {
if term_colors {
os.setenv('VCOLORS', 'always', true)
}
os.mkdir_all(vcheckfolder) or {}
defer {
os.rmdir_all(vcheckfolder) or {}
}
for i := 0; i < files_paths.len; i++ {
file_path := files_paths[i]
if os.is_dir(file_path) {
@ -75,7 +81,7 @@ fn main() {
res += mdfile.check()
}
if res.errors == 0 && show_progress {
term.clear_previous_line()
clear_previous_line()
}
if res.warnings > 0 || res.errors > 0 || res.oks > 0 {
println('\nWarnings: $res.warnings | Errors: $res.errors | OKs: $res.oks')
@ -131,9 +137,7 @@ fn eline(file_path string, lnumber int, column int, message string) string {
return btext('$file_path:${lnumber + 1}:${column + 1}:') + btext(rtext(' error: $message'))
}
const (
default_command = 'compile'
)
const default_command = 'compile'
struct VCodeExample {
mut:
@ -160,7 +164,7 @@ mut:
fn (mut f MDFile) progress(message string) {
if show_progress {
term.clear_previous_line()
clear_previous_line()
println('File: ${f.path:-30s}, Lines: ${f.lines.len:5}, $message')
}
}
@ -394,6 +398,7 @@ fn (mut f MDFile) debug() {
}
fn cmdexecute(cmd string) int {
verbose_println(cmd)
res := os.execute(cmd)
if res.exit_code < 0 {
return 1
@ -405,6 +410,7 @@ fn cmdexecute(cmd string) int {
}
fn silent_cmdexecute(cmd string) int {
verbose_println(cmd)
res := os.execute(cmd)
return res.exit_code
}
@ -426,7 +432,9 @@ fn (mut f MDFile) check_examples() CheckResult {
}
fname := os.base(f.path).replace('.md', '_md')
uid := rand.ulid()
vfile := os.join_path(os.temp_dir(), 'check_${fname}_example_${e.sline}__${e.eline}__${uid}.v')
cfile := os.join_path(vcheckfolder, '${uid}.c')
vfile := os.join_path(vcheckfolder, 'check_${fname}_example_${e.sline}__${e.eline}__${uid}.v')
efile := os.join_path(vcheckfolder, 'check_${fname}_example_${e.sline}__${e.eline}__${uid}.exe')
mut should_cleanup_vfile := true
// eprintln('>>> checking example $vfile ...')
vcontent := e.text.join('\n') + '\n'
@ -438,8 +446,7 @@ fn (mut f MDFile) check_examples() CheckResult {
fmt_res := if nofmt { 0 } else { get_fmt_exit_code(vfile, vexe) }
match command {
'compile' {
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o x.c ${os.quoted_path(vfile)}')
os.rm('x.c') or {}
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o ${os.quoted_path(efile)} ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example failed to compile'))
@ -454,9 +461,24 @@ fn (mut f MDFile) check_examples() CheckResult {
}
oks++
}
'cgen' {
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example failed to generate C code'))
}
if fmt_res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example is not formatted'))
}
eprintln(vcontent)
should_cleanup_vfile = false
errors++
continue
}
oks++
}
'globals' {
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -enable-globals -o x.c ${os.quoted_path(vfile)}')
os.rm('x.c') or {}
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -enable-globals -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, '`example failed to compile with -enable-globals'))
@ -472,7 +494,7 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'live' {
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -live -o x.c ${os.quoted_path(vfile)}')
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -live -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example failed to compile with -live'))
@ -488,8 +510,7 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'failcompile' {
res := silent_cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o x.c ${os.quoted_path(vfile)}')
os.rm('x.c') or {}
res := silent_cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)}')
if res == 0 || fmt_res != 0 {
if res == 0 {
eprintln(eline(f.path, e.sline, 0, '`failcompile` example compiled'))
@ -533,12 +554,14 @@ fn (mut f MDFile) check_examples() CheckResult {
}
'nofmt' {}
else {
eprintln(eline(f.path, e.sline, 0, 'unrecognized command: "$command", use one of: wip/ignore/compile/failcompile/oksyntax/badsyntax'))
eprintln(eline(f.path, e.sline, 0, 'unrecognized command: "$command", use one of: wip/ignore/compile/cgen/failcompile/oksyntax/badsyntax/nofmt'))
should_cleanup_vfile = false
errors++
}
}
}
os.rm(cfile) or {}
os.rm(efile) or {}
if should_cleanup_vfile {
os.rm(vfile) or { panic(err) }
}
@ -548,3 +571,16 @@ fn (mut f MDFile) check_examples() CheckResult {
oks: oks
}
}
fn verbose_println(message string) {
if is_verbose {
println(message)
}
}
fn clear_previous_line() {
if is_verbose {
return
}
term.clear_previous_line()
}

View File

@ -76,7 +76,7 @@ SUBCMD:
// Snooped from cmd/v/v.v, vlib/v/pref/pref.v
const (
auto_complete_commands = [
auto_complete_commands = [
// simple_cmd
'ast',
'doc',
@ -114,7 +114,6 @@ const (
'help',
'new',
'init',
'complete',
'translate',
'self',
'search',
@ -130,8 +129,13 @@ const (
'run',
'build',
'build-module',
'missdoc',
]
auto_complete_flags = [
// Entries in the flag arrays below should be entered as is:
// * Short flags, e.g.: "-v", should be entered: '-v'
// * Long flags, e.g.: "--version", should be entered: '--version'
// * Single-dash flags, e.g.: "-version", should be entered: '-version'
auto_complete_flags = [
'-apk',
'-show-timings',
'-check-syntax',
@ -150,6 +154,7 @@ const (
'-autofree',
'-compress',
'-freestanding',
'-no-parallel',
'-no-preludes',
'-prof',
'-profile',
@ -190,7 +195,7 @@ const (
'-version',
'--version',
]
auto_complete_flags_doc = [
auto_complete_flags_doc = [
'-all',
'-f',
'-h',
@ -203,12 +208,13 @@ const (
'-pos',
'-no-timestamp',
'-inline-assets',
'-theme-dir',
'-open',
'-p',
'-s',
'-l',
]
auto_complete_flags_fmt = [
auto_complete_flags_fmt = [
'-c',
'-diff',
'-l',
@ -216,7 +222,7 @@ const (
'-debug',
'-verify',
]
auto_complete_flags_bin2v = [
auto_complete_flags_bin2v = [
'-h',
'--help',
'-m',
@ -226,22 +232,46 @@ const (
'-w',
'--write',
]
auto_complete_flags_shader = [
'help',
'h',
'force-update',
'u',
'verbose',
'v',
'slang',
'l',
'output',
'o',
auto_complete_flags_shader = [
'--help',
'-h',
'--force-update',
'-u',
'--verbose',
'-v',
'--slang',
'-l',
'--output',
'-o',
]
auto_complete_flags_self = [
auto_complete_flags_missdoc = [
'--help',
'-h',
'--tags',
'-t',
'--deprecated',
'-d',
'--private',
'-p',
'--no-line-numbers',
'-n',
'--exclude',
'-e',
'--relative-paths',
'-r',
'--js',
'--verify',
'--diff',
]
auto_complete_flags_bump = [
'--patch',
'--minor',
'--major',
]
auto_complete_flags_self = [
'-prod',
]
auto_complete_compilers = [
auto_complete_compilers = [
'cc',
'gcc',
'tcc',
@ -371,12 +401,17 @@ fn auto_complete_request(args []string) []string {
parent_command = parts[i]
break
}
get_flags := fn (base []string, flag string) []string {
if flag.len == 1 { return base
} else { return base.filter(it.starts_with(flag))
}
}
if part.starts_with('-') { // 'v -<tab>' -> flags.
if part.starts_with('-') { // 'v [subcmd] -<tab>' or 'v [subcmd] --<tab>'-> flags.
get_flags := fn (base []string, flag string) []string {
mut results := []string{}
for entry in base {
if entry.starts_with(flag) {
results << entry
}
}
return results
}
match parent_command {
'bin2v' { // 'v bin2v -<tab>'
list = get_flags(auto_complete_flags_bin2v, part)
@ -396,6 +431,12 @@ fn auto_complete_request(args []string) []string {
'shader' { // 'v shader -<tab>' -> flags.
list = get_flags(auto_complete_flags_shader, part)
}
'missdoc' { // 'v missdoc -<tab>' -> flags.
list = get_flags(auto_complete_flags_missdoc, part)
}
'bump' { // 'v bump -<tab>' -> flags.
list = get_flags(auto_complete_flags_bump, part)
}
else {
for flag in auto_complete_flags {
if flag == part {
@ -413,6 +454,11 @@ fn auto_complete_request(args []string) []string {
}
}
}
// Clear the list if the result is identical to the part examined
// (the flag must have already been completed)
if list.len == 1 && part == list[0] {
list.clear()
}
} else {
match part {
'help' { // 'v help <tab>' -> top level commands except "help".

View File

@ -77,6 +77,8 @@ vls.log
fn gitattributes_content() string {
return '*.v linguist-language=V text=auto eol=lf
*.vv linguist-language=V text=auto eol=lf
*.vsh linguist-language=V text=auto eol=lf
**/v.mod linguist-language=V text=auto eol=lf
'
}
@ -158,7 +160,7 @@ fn create(args []string) {
if c.version == '' {
c.version = default_version
}
default_license := 'MIT'
default_license := os.getenv_opt('VLICENSE') or { 'MIT' }
c.license = os.input('Input your project license: ($default_license) ')
if c.license == '' {
c.license = default_license

View File

@ -5,7 +5,7 @@ const test_path = 'vcreate_test'
fn init_and_check() ? {
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
assert os.read_file('vcreate_test.v') ? == [
assert os.read_file('vcreate_test.v')? == [
'module main\n',
'fn main() {',
" println('Hello World!')",
@ -13,7 +13,7 @@ fn init_and_check() ? {
'',
].join_lines()
assert os.read_file('v.mod') ? == [
assert os.read_file('v.mod')? == [
'Module {',
" name: 'vcreate_test'",
" description: ''",
@ -24,7 +24,7 @@ fn init_and_check() ? {
'',
].join_lines()
assert os.read_file('.gitignore') ? == [
assert os.read_file('.gitignore')? == [
'# Binaries for programs and plugins',
'main',
'vcreate_test',
@ -37,13 +37,15 @@ fn init_and_check() ? {
'',
].join_lines()
assert os.read_file('.gitattributes') ? == [
assert os.read_file('.gitattributes')? == [
'*.v linguist-language=V text=auto eol=lf',
'*.vv linguist-language=V text=auto eol=lf',
'*.vsh linguist-language=V text=auto eol=lf',
'**/v.mod linguist-language=V text=auto eol=lf',
'',
].join_lines()
assert os.read_file('.editorconfig') ? == [
assert os.read_file('.editorconfig')? == [
'[*]',
'charset = utf-8',
'end_of_line = lf',
@ -64,9 +66,9 @@ fn test_v_init() ? {
defer {
os.rmdir_all(dir) or {}
}
os.chdir(dir) ?
os.chdir(dir)?
init_and_check() ?
init_and_check()?
}
fn test_v_init_in_git_dir() ? {
@ -76,24 +78,24 @@ fn test_v_init_in_git_dir() ? {
defer {
os.rmdir_all(dir) or {}
}
os.chdir(dir) ?
os.chdir(dir)?
os.execute_or_exit('git init .')
init_and_check() ?
init_and_check()?
}
fn test_v_init_no_overwrite_gitignore() ? {
dir := os.join_path(os.temp_dir(), test_path)
os.rmdir_all(dir) or {}
os.mkdir(dir) or {}
os.write_file('$dir/.gitignore', 'blah') ?
os.write_file('$dir/.gitignore', 'blah')?
defer {
os.rmdir_all(dir) or {}
}
os.chdir(dir) ?
os.chdir(dir)?
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
assert os.read_file('.gitignore') ? == 'blah'
assert os.read_file('.gitignore')? == 'blah'
}
fn test_v_init_no_overwrite_gitattributes_and_editorconfig() ? {
@ -112,15 +114,15 @@ indent_size = 4
dir := os.join_path(os.temp_dir(), test_path)
os.rmdir_all(dir) or {}
os.mkdir(dir) or {}
os.write_file('$dir/.gitattributes', git_attributes_content) ?
os.write_file('$dir/.editorconfig', editor_config_content) ?
os.write_file('$dir/.gitattributes', git_attributes_content)?
os.write_file('$dir/.editorconfig', editor_config_content)?
defer {
os.rmdir_all(dir) or {}
}
os.chdir(dir) ?
os.chdir(dir)?
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
assert os.read_file('.gitattributes') ? == git_attributes_content
assert os.read_file('.editorconfig') ? == editor_config_content
assert os.read_file('.gitattributes')? == git_attributes_content
assert os.read_file('.editorconfig')? == editor_config_content
}

View File

@ -12,70 +12,13 @@ import v.doc
import v.pref
const (
css_js_assets = ['doc.css', 'normalize.css', 'doc.js', 'dark-mode.js']
res_path = os.resource_abs_path('resources')
favicons_path = os.join_path(res_path, 'favicons')
link_svg = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>'
html_content = '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="x-ua-compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }} | vdoc</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap" rel="stylesheet">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
{{ head_assets }}
</head>
<body>
<div><a id="skip-to-content-link" href="#main-content">Skip to content</a></div>
<div id="page">
<header class="doc-nav hidden">
<div class="heading-container">
<div class="heading">
<div class="info">
<div class="module">{{ head_name }}</div>
<div class="toggle-version-container">
<span>{{ version }}</span>
<div id="dark-mode-toggle" role="switch" aria-checked="false" aria-label="Toggle dark mode">{{ light_icon }}{{ dark_icon }}</div>
</div>
{{ menu_icon }}
</div>
<input type="text" id="search" placeholder="Search... (beta)" autocomplete="off">
</div>
</div>
<nav class="search hidden"></nav>
<nav class="content hidden">
<ul>
{{ toc_links }}
</ul>
</nav>
</header>
<div class="doc-scrollview" id="main-content">
<div class="doc-container">
<div class="doc-content">
{{ contents }}
<div class="footer">
{{ footer_content }}
</div>
</div>
{{ right_content }}
</div>
</div>
</div>
{{ footer_assets }}
<script async src="search_index.js" type="text/javascript"></script>
</body>
</html>'
css_js_assets = ['doc.css', 'normalize.css', 'doc.js', 'dark-mode.js']
default_theme = os.resource_abs_path('theme')
link_svg = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>'
single_quote = "'"
double_quote = '"'
no_quotes_replacement = [single_quote, '', double_quote, '']
)
enum HighlightTokenTyp {
@ -150,7 +93,7 @@ fn (mut vd VDoc) render_static_html(out Output) {
fn (vd VDoc) get_resource(name string, out Output) string {
cfg := vd.cfg
path := os.join_path(res_path, name)
path := os.join_path(cfg.theme_dir, name)
mut res := os.read_file(path) or { panic('vdoc: could not read $path') }
/*
if minify {
@ -254,7 +197,8 @@ fn (vd VDoc) gen_html(d doc.Doc) string {
write_toc(cn, mut symbols_toc)
} // write head
// write css
version := if vd.manifest.version.len != 0 { vd.manifest.version } else { '' }
mut version := if vd.manifest.version.len != 0 { vd.manifest.version } else { '' }
version = [version, @VHASH].join(' ')
header_name := if cfg.is_multi && vd.docs.len > 1 {
os.file_name(os.real_path(cfg.input_path))
} else {
@ -300,8 +244,9 @@ fn (vd VDoc) gen_html(d doc.Doc) string {
}
modules_toc_str := modules_toc.str()
symbols_toc_str := symbols_toc.str()
result := html_content.replace('{{ title }}', d.head.name).replace('{{ head_name }}',
header_name).replace('{{ version }}', version).replace('{{ light_icon }}', vd.assets['light_icon']).replace('{{ dark_icon }}',
result := (os.read_file(os.join_path(cfg.theme_dir, 'index.html')) or { panic(err) }).replace('{{ title }}',
d.head.name).replace('{{ head_name }}', header_name).replace('{{ version }}',
version).replace('{{ light_icon }}', vd.assets['light_icon']).replace('{{ dark_icon }}',
vd.assets['dark_icon']).replace('{{ menu_icon }}', vd.assets['menu_icon']).replace('{{ head_assets }}',
if cfg.inline_assets {
'\n${tabs[0]}<style>' + vd.assets['doc_css'] + '</style>\n${tabs[0]}<style>' +
@ -357,6 +302,8 @@ fn html_highlight(code string, tb &ast.Table) string {
"'$tok.lit'"
} else if typ == .char {
'`$tok.lit`'
} else if typ == .comment {
if tok.lit != '' && tok.lit[0] == 1 { '//${tok.lit[1..]}' } else { '//$tok.lit' }
} else {
tok.lit
}
@ -379,7 +326,8 @@ fn html_highlight(code string, tb &ast.Table) string {
tok_typ = .builtin
} else if next_tok.kind == .lcbr {
tok_typ = .symbol
} else if next_tok.kind == .lpar {
} else if next_tok.kind == .lpar || (!tok.lit[0].is_capital()
&& next_tok.kind == .lt && next_tok.pos == tok.pos + tok.lit.len) {
tok_typ = .function
} else {
tok_typ = .name
@ -400,14 +348,15 @@ fn html_highlight(code string, tb &ast.Table) string {
.key_true, .key_false {
tok_typ = .boolean
}
.lpar, .lcbr, .rpar, .rcbr, .lsbr, .rsbr, .semicolon, .colon, .comma, .dot {
.lpar, .lcbr, .rpar, .rcbr, .lsbr, .rsbr, .semicolon, .colon, .comma, .dot,
.dotdot, .ellipsis {
tok_typ = .punctuation
}
else {
if token.is_key(tok.lit) || token.is_decl(tok.kind) {
tok_typ = .keyword
} else if tok.kind == .decl_assign || tok.kind.is_assign() || tok.is_unary()
|| tok.kind.is_relational() || tok.kind.is_infix() {
|| tok.kind.is_relational() || tok.kind.is_infix() || tok.kind.is_postfix() {
tok_typ = .operator
}
}
@ -421,7 +370,7 @@ fn html_highlight(code string, tb &ast.Table) string {
break
}
} else {
buf.write_byte(code[i])
buf.write_u8(code[i])
i++
}
}
@ -444,8 +393,9 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
highlighted_code := html_highlight(dn.content, tb)
node_class := if dn.kind == .const_group { ' const' } else { '' }
sym_name := get_sym_name(dn)
has_deprecated := 'deprecated' in dn.tags
mut tags := dn.tags.filter(it != 'deprecated')
mut deprecated_tags := dn.tags.filter(it.starts_with('deprecated'))
deprecated_tags.sort()
mut tags := dn.tags.filter(!it.starts_with('deprecated'))
tags.sort()
mut node_id := get_node_id(dn)
mut hash_link := if !head { ' <a href="#$node_id">#</a>' } else { '' }
@ -465,13 +415,12 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
}
dnw.write_string('</div>')
}
if tags.len > 0 || has_deprecated {
mut attributes := if has_deprecated {
'<div class="attribute attribute-deprecated">deprecated</div>'
} else {
''
}
attributes += tags.map('<div class="attribute">$it</div>').join('')
if deprecated_tags.len > 0 {
attributes := deprecated_tags.map('<div class="attribute attribute-deprecated">${no_quotes(it)}</div>').join('')
dnw.writeln('<div class="attributes">$attributes</div>')
}
if tags.len > 0 {
attributes := tags.map('<div class="attribute">$it</div>').join('')
dnw.writeln('<div class="attributes">$attributes</div>')
}
if !head && dn.content.len > 0 {
@ -485,8 +434,8 @@ fn doc_node_html(dn doc.DocNode, link string, head bool, include_examples bool,
example_title := if examples.len > 1 { 'Examples' } else { 'Example' }
dnw.writeln('<section class="doc-node examples"><h4>$example_title</h4>')
for example in examples {
// hl_example := html_highlight(example, tb)
dnw.writeln('<pre><code class="language-v">$example</code></pre>')
hl_example := html_highlight(example, tb)
dnw.writeln('<pre><code class="language-v">$hl_example</code></pre>')
}
dnw.writeln('</section>')
}
@ -553,3 +502,7 @@ fn write_toc(dn doc.DocNode, mut toc strings.Builder) {
}
toc.writeln('</li>')
}
fn no_quotes(s string) string {
return s.replace_each(no_quotes_replacement)
}

View File

@ -1,7 +1,13 @@
module main
const (
source_root = 'temp'
source_root = 'temp' // some const
another = int(5) //
)
const (
windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED //
)
Used to indicate that you don't care what the window position is.
fn funky()
funky - comment for function below
funky - comment for function below

View File

@ -1,6 +1,11 @@
module main
const (
source_root = 'temp'
source_root = 'temp' // some const
another = int(5) //
)
fn funky()
const (
windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED //
)
fn funky()

View File

@ -1,5 +1,12 @@
pub const (
source_root = 'temp'
source_root = 'temp' // some const
another = int(5) //
)
// Used to indicate that you don't care what the window position is.
pub const (
windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED //
)
// funky - comment for function below

View File

@ -16,7 +16,7 @@ fn find_diff_cmd() string {
fn test_vet() ? {
os.setenv('VCOLORS', 'never', true)
os.chdir(vroot) ?
os.chdir(vroot)?
test_dir := 'cmd/tools/vdoc/tests/testdata'
main_files := get_main_files_in_dir(test_dir)
fails := check_path(vexe, test_dir, main_files)

View File

Before

Width:  |  Height:  |  Size: 175 B

After

Width:  |  Height:  |  Size: 175 B

View File

Before

Width:  |  Height:  |  Size: 642 B

After

Width:  |  Height:  |  Size: 642 B

View File

@ -24,18 +24,18 @@
--menu-search-badge-background-hover-color: #0000004d;
--toc-text-color: #2779bd;
--toc-indicator-color: #4299e1;
--code-default-text-color: #5c6e74;
--code-default-text-color: #2c3e64;
--code-background-color: #edf2f7;
--code-keyword-text-color: #2b6cb0;
--code-builtin-text-color: #0a0a0a;
--code-function-text-color: #319795;
--code-builtin-text-color: #219321;
--code-function-text-color: #288341;
--code-comment-text-color: #93a1a1;
--code-punctuation-text-color: #999999;
--code-punctuation-text-color: #696969;
--code-symbol-text-color: #702459;
--code-operator-text-color: #a67f59;
--code-operator-text-color: #864f29;
--attribute-deprecated-background-color: #f59f0b48;
--attribute-deprecated-text-color: #92400e;
--attribute-text-color: #000000af;
--attribute-text-color: #000000cf;
}
:root.dark .dark-icon {
display: none;
@ -76,6 +76,7 @@
--code-comment-text-color: #a0aec0;
--code-punctuation-text-color: #a0aec0;
--code-symbol-text-color: #ed64a6;
--code-operator-text-color: #a67f59;
--attribute-background-color: #ffffff20;
--attribute-text-color: #ffffffaf;
--attribute-deprecated-text-color: #fef3c7;
@ -417,6 +418,8 @@ body {
background-color: var(--code-background-color);
color: var(--attribute-text-color);
margin-right: 0.8rem;
font-family: "Jetbrains Mono", monospace;
font-size: 0.9rem;
}
.doc-content > .doc-node > .attributes > .attribute-deprecated {
background-color: var(--attribute-deprecated-background-color);
@ -612,6 +615,7 @@ pre {
.token.keyword {
color: #2b6cb0;
color: var(--code-keyword-text-color);
font-weight: bold;
}
.token.function {
color: #319795;

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 853 B

After

Width:  |  Height:  |  Size: 853 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="x-ua-compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }} | vdoc</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap" rel="stylesheet">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
{{ head_assets }}
</head>
<body>
<div><a id="skip-to-content-link" href="#main-content">Skip to content</a></div>
<div id="page">
<header class="doc-nav hidden">
<div class="heading-container">
<div class="heading">
<div class="info">
<div class="module">{{ head_name }}</div>
<div class="toggle-version-container">
<span>{{ version }}</span>
<div id="dark-mode-toggle" role="switch" aria-checked="false" aria-label="Toggle dark mode">{{ light_icon }}{{ dark_icon }}</div>
</div>
{{ menu_icon }}
</div>
<input type="text" id="search" placeholder="Search... (beta)" autocomplete="off">
</div>
</div>
<nav class="search hidden"></nav>
<nav class="content hidden">
<ul>
{{ toc_links }}
</ul>
</nav>
</header>
<div class="doc-scrollview" id="main-content">
<div class="doc-container">
<div class="doc-content">
{{ contents }}
<div class="footer">
{{ footer_content }}
</div>
</div>
{{ right_content }}
</div>
</div>
</div>
{{ footer_assets }}
<script async src="search_index.js"></script>
</body>
</html>

View File

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 499 B

View File

Before

Width:  |  Height:  |  Size: 350 B

After

Width:  |  Height:  |  Size: 350 B

View File

Before

Width:  |  Height:  |  Size: 201 B

After

Width:  |  Height:  |  Size: 201 B

View File

@ -161,6 +161,13 @@ fn color_highlight(code string, tb &ast.Table) string {
.char {
lit = term.yellow('`$tok.lit`')
}
.comment {
lit = if tok.lit != '' && tok.lit[0] == 1 {
'//${tok.lit[1..]}'
} else {
'//$tok.lit'
}
}
.keyword {
lit = term.bright_blue(tok.lit)
}
@ -206,15 +213,18 @@ fn color_highlight(code string, tb &ast.Table) string {
} else if
next_tok.kind in [.lcbr, .rpar, .eof, .comma, .pipe, .name, .rcbr, .assign, .key_pub, .key_mut, .pipe, .comma]
&& prev.kind in [.name, .amp, .rsbr, .key_type, .assign, .dot, .question, .rpar, .key_struct, .key_enum, .pipe, .key_interface]
&& (tok.lit[0].ascii_str().is_upper() || prev_prev.lit in ['C', 'JS']) {
&& ((tok.lit != '' && tok.lit[0].is_capital())
|| prev_prev.lit in ['C', 'JS']) {
tok_typ = .symbol
} else if next_tok.kind in [.lpar, .lt] {
} else if next_tok.kind == .lpar
|| (!(tok.lit != '' && tok.lit[0].is_capital()) && next_tok.kind == .lt
&& next_tok.pos == tok.pos + tok.lit.len) {
tok_typ = .function
} else if next_tok.kind == .dot {
if tok.lit in ['C', 'JS'] {
tok_typ = .prefix
} else {
if tok.lit[0].ascii_str().is_upper() {
if tok.lit != '' && tok.lit[0].is_capital() {
tok_typ = .symbol
} else {
tok_typ = .module_
@ -241,7 +251,8 @@ fn color_highlight(code string, tb &ast.Table) string {
.key_true, .key_false {
tok_typ = .boolean
}
.lpar, .lcbr, .rpar, .rcbr, .lsbr, .rsbr, .semicolon, .colon, .comma, .dot {
.lpar, .lcbr, .rpar, .rcbr, .lsbr, .rsbr, .semicolon, .colon, .comma, .dot,
.dotdot, .ellipsis {
tok_typ = .punctuation
}
.key_none {
@ -251,7 +262,7 @@ fn color_highlight(code string, tb &ast.Table) string {
if token.is_key(tok.lit) || token.is_decl(tok.kind) {
tok_typ = .keyword
} else if tok.kind == .decl_assign || tok.kind.is_assign() || tok.is_unary()
|| tok.kind.is_relational() || tok.kind.is_infix() {
|| tok.kind.is_relational() || tok.kind.is_infix() || tok.kind.is_postfix() {
tok_typ = .operator
}
}
@ -266,7 +277,7 @@ fn color_highlight(code string, tb &ast.Table) string {
tok = next_tok
next_tok = s.scan()
} else {
buf.write_byte(code[i])
buf.write_u8(code[i])
i++
}
}

View File

@ -53,6 +53,7 @@ mut:
include_examples bool = true
include_comments bool // for plaintext
inline_assets bool
theme_dir string = default_theme
no_timestamp bool
output_path string
output_type OutputType = .unset
@ -103,13 +104,17 @@ fn (vd VDoc) gen_plaintext(d doc.Doc) string {
d.head.merge_comments_without_examples()
}
if comments.trim_space().len > 0 {
pw.writeln(comments.split_into_lines().map(' ' + it).join('\n'))
pw.writeln(indent(comments))
}
}
vd.write_plaintext_content(d.contents.arr(), mut pw)
return pw.str()
}
fn indent(s string) string {
return ' ' + s.replace('\n', '\n ')
}
fn (vd VDoc) write_plaintext_content(contents []doc.DocNode, mut pw strings.Builder) {
cfg := vd.cfg
for cn in contents {
@ -120,12 +125,24 @@ fn (vd VDoc) write_plaintext_content(contents []doc.DocNode, mut pw strings.Buil
pw.writeln(cn.content)
}
if cn.comments.len > 0 && cfg.include_comments {
comments := if cfg.include_examples {
cn.merge_comments()
} else {
cn.merge_comments_without_examples()
comments := cn.merge_comments_without_examples()
pw.writeln(indent(comments.trim_space()))
if cfg.include_examples {
examples := cn.examples()
for ex in examples {
pw.write_string(' Example: ')
mut fex := ex
if ex.index_u8(`\n`) >= 0 {
// multi-line example
pw.write_u8(`\n`)
fex = indent(ex)
}
if cfg.is_color {
fex = color_highlight(fex, vd.docs[0].table)
}
pw.writeln(fex)
}
}
pw.writeln(comments.trim_space().split_into_lines().map(' ' + it).join('\n'))
}
if cfg.show_loc {
pw.writeln('Location: $cn.file_path:${cn.pos.line_nr + 1}\n')
@ -227,8 +244,8 @@ fn (vd VDoc) get_readme(path string) string {
fn (vd VDoc) emit_generate_err(err IError) {
cfg := vd.cfg
mut err_msg := err.msg
if err.code == 1 {
mut err_msg := err.msg()
if err.code() == 1 {
mod_list := get_modules_list(cfg.input_path, []string{})
println('Available modules:\n==================')
for mod in mod_list {
@ -378,6 +395,9 @@ fn (mut vd VDoc) generate_docs_from_file() {
vd.render_search_index(out)
// move favicons to target directory
println('Copying favicons...')
favicons_path := os.join_path(cfg.theme_dir, 'favicons')
favicons := os.ls(favicons_path) or { panic(err) }
for favicon in favicons {
favicon_path := os.join_path(favicons_path, favicon)
@ -423,6 +443,9 @@ fn parse_arguments(args []string) Config {
'-inline-assets' {
cfg.inline_assets = true
}
'-theme-dir' {
cfg.theme_dir = cmdline.option(current_args, '-theme-dir', default_theme)
}
'-l' {
cfg.show_loc = true
}
@ -444,7 +467,7 @@ fn parse_arguments(args []string) Config {
exit(1)
}
selected_platform := doc.platform_from_string(platform_str) or {
eprintln(err.msg)
eprintln(err.msg())
exit(1)
}
cfg.platform = selected_platform

Some files were not shown because too many files have changed in this diff Show More