Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors building valval example on CentOS 8/vlang V 0.1.30 1ee5764 #14

Open
lospejos opened this issue Dec 16, 2020 · 9 comments
Open

Errors building valval example on CentOS 8/vlang V 0.1.30 1ee5764 #14

lospejos opened this issue Dec 16, 2020 · 9 comments

Comments

@lospejos
Copy link

lospejos commented Dec 16, 2020

Environment:
V 0.1.30 1ee5764
CentOS Linux release 8.2.2004 x86_64

V is compiled from sources.
When trying to run Valval example from https://github.com/valvalio/valval/blob/master/example/example.v

Getting plenty of errors. Among them:

~/.vmodules/valval/valval.v:200:2: error: unnecessary `()` in `if` condition, use `if expr {` instead of `if (expr) {`.
~/.vmodules/valval/valval.v:204:2: error: unnecessary `()` in `if` condition, use `if expr {` instead of `if (expr) {`.
~/.vmodules/valval/valval.v:233:22: error: unknown function: net.listen
~/.vmodules/valval/valval.v:234:29: error: unexpected `or` block, the function `accept` does not return an optional
~/.vmodules/valval/valval.v:235:20: error: unexpected `or` block, the function `close` does not return an optional
~/.vmodules/valval/valval.v:240:22: error: invalid argument 1 to `readall`: expected `net.Socket`, not `void`
~/.vmodules/valval/valval.v:243:26: error: unexpected `or` block, the function `write` does not return an optional
~/.vmodules/valval/valval.v:245:26: error: unexpected `or` block, the function `write` does not return an optional


etc

Is this Valval version functional/working? What V version does it support?

Full errors log is attached here:
valval_sample_errors.txt

@DavidSatimeWallin
Copy link
Collaborator

Hi @lospejos !
The current version of Valval only supports v0.1.24 of V.
We're currently in the process of making sure it supports v0.1.30 but it's not yet done.

@lospejos
Copy link
Author

lospejos commented Dec 18, 2020

Hi @lospejos !
The current version of Valval only supports v0.1.24 of V.
We're currently in the process of making sure it supports v0.1.30 but it's not yet done.

Glad to hear it! I hope you'll successfully adopt Valval to a new versions of V. Do you have any estimations about when it will be approximately completed? Thanks!

@DavidSatimeWallin
Copy link
Collaborator

No estimations at all right now but I'm hoping maybe during Feb 2021

@lospejos
Copy link
Author

BTW FYI there is a new V version 0.2 announced with a big changelog. Hope this will not break your upcoming updates of Valval.

@lospejos
Copy link
Author

Authors told me, that all changes are in master branch of V, FYI

@DavidSatimeWallin
Copy link
Collaborator

Yeah I've seen, thanks for reminding though. Pretty much every release up until version 1 will mean lots of breaking stuff. It will not be possible for us to keep Valval supporting of every V-lang version until we hit v1 of V

@ghost
Copy link

ghost commented Feb 23, 2021

Uh oh, Valval on V 0.2.2 broke down!
/Users/huanghe/.vmodules/valval/valval.v:13:2: warning: const names cannot contain uppercase letters, use snake_case instead
11 |
12 | const (
13 | VERSION = '0.1.4'
| ~~~~~~~
14 | V_VERSION = '0.1.24'
15 | HTTP_404 = 'HTTP/1.1 404 Not Found\r\nContent-Type: text/plain\r\n\r\n404 Not Found'
/Users/huanghe/.vmodules/valval/valval.v:14:2: warning: const names cannot contain uppercase letters, use snake_case instead
12 | const (
13 | VERSION = '0.1.4'
14 | V_VERSION = '0.1.24'
| ~~~~~~~~~
15 | HTTP_404 = 'HTTP/1.1 404 Not Found\r\nContent-Type: text/plain\r\n\r\n404 Not Found'
16 | HTTP_413 = 'HTTP/1.1 413 Request Entity Too Large\r\nContent-Type: text/plain\r\n\r\n413 Request Entity Too Large'
/Users/huanghe/.vmodules/valval/valval.v:15:2: warning: const names cannot contain uppercase letters, use snake_case instead
13 | VERSION = '0.1.4'
14 | V_VERSION = '0.1.24'
15 | HTTP_404 = 'HTTP/1.1 404 Not Found\r\nContent-Type: text/plain\r\n\r\n404 Not Found'
| ~~~~~~~~
16 | HTTP_413 = 'HTTP/1.1 413 Request Entity Too Large\r\nContent-Type: text/plain\r\n\r\n413 Request Entity Too Large'
17 | HTTP_500 = 'HTTP/1.1 500 Internal Server Error\r\nContent-Type: text/plain\r\n\r\n500 Internal Server Error'
/Users/huanghe/.vmodules/valval/valval.v:16:2: warning: const names cannot contain uppercase letters, use snake_case instead
14 | V_VERSION = '0.1.24'
15 | HTTP_404 = 'HTTP/1.1 404 Not Found\r\nContent-Type: text/plain\r\n\r\n404 Not Found'
16 | HTTP_413 = 'HTTP/1.1 413 Request Entity Too Large\r\nContent-Type: text/plain\r\n\r\n413 Request Entity Too Large'
| ~~~~~~~~
17 | HTTP_500 = 'HTTP/1.1 500 Internal Server Error\r\nContent-Type: text/plain\r\n\r\n500 Internal Server Error'
18 | POST_BODY_LIMIT = 1024 * 1024 * 20 // 20MB
/Users/huanghe/.vmodules/valval/valval.v:17:2: warning: const names cannot contain uppercase letters, use snake_case instead
15 | HTTP_404 = 'HTTP/1.1 404 Not Found\r\nContent-Type: text/plain\r\n\r\n404 Not Found'
16 | HTTP_413 = 'HTTP/1.1 413 Request Entity Too Large\r\nContent-Type: text/plain\r\n\r\n413 Request Entity Too Large'
17 | HTTP_500 = 'HTTP/1.1 500 Internal Server Error\r\nContent-Type: text/plain\r\n\r\n500 Internal Server Error'
| ~~~~~~~~
18 | POST_BODY_LIMIT = 1024 * 1024 * 20 // 20MB
19 | API_KEY_FLAG = 'valvalapikey' // the param name won't be used anywhere else
/Users/huanghe/.vmodules/valval/valval.v:18:2: warning: const names cannot contain uppercase letters, use snake_case instead
16 | HTTP_413 = 'HTTP/1.1 413 Request Entity Too Large\r\nContent-Type: text/plain\r\n\r\n413 Request Entity Too Large'
17 | HTTP_500 = 'HTTP/1.1 500 Internal Server Error\r\nContent-Type: text/plain\r\n\r\n500 Internal Server Error'
18 | POST_BODY_LIMIT = 1024 * 1024 * 20 // 20MB
| ~~~~~~~~~~~~~~~
19 | API_KEY_FLAG = 'valvalapikey' // the param name won't be used anywhere else
20 | )
/Users/huanghe/.vmodules/valval/valval.v:19:2: warning: const names cannot contain uppercase letters, use snake_case instead
17 | HTTP_500 = 'HTTP/1.1 500 Internal Server Error\r\nContent-Type: text/plain\r\n\r\n500 Internal Server Error'
18 | POST_BODY_LIMIT = 1024 * 1024 * 20 // 20MB
19 | API_KEY_FLAG = 'valvalapikey' // the param name won't be used anywhere else
| ~~~~~~~~~~~~
20 | )
21 |
/Users/huanghe/.vmodules/valval/valval.v:64:8: warning: use (mut f Foo) instead of (f mut Foo)
62 | }
63 |
64 | pub fn (res mut Response) set_header(key string, value string) {
| ~~~~~~~~~~~~~~~~~~
65 | res.headers[key] = value
66 | }
/Users/huanghe/.vmodules/valval/valval.v:119:8: warning: use (mut f Foo) instead of (f mut Foo)
117 | }
118 |
119 | pub fn (view mut View) set(key string, data string) {
| ~~~~~~~~~~~~~~~
120 | // data should be a json str of obj / str / int / bool / list ..
121 | view.context[key.trim_space()] = data
/Users/huanghe/.vmodules/valval/valval.v:142:8: warning: use (mut f Foo) instead of (f mut Foo)
140 | }
141 |
142 | pub fn (app mut App) route(path string, func fn(Request) Response) {
| ~~~~~~~~~~~~~
143 | // route path should not be ends with /
144 | rpath := path.trim_right('/')
/Users/huanghe/.vmodules/valval/valval.v:148:8: warning: use (mut f Foo) instead of (f mut Foo)
146 | }
147 |
148 | pub fn (app mut App) register(path string, func fn(Request) Response) {
| ~~~~~~~~~~~~~
149 | // as same as route
150 | app.route(path, func)
/Users/huanghe/.vmodules/valval/valval.v:153:8: warning: use (mut f Foo) instead of (f mut Foo)
151 | }
152 |
153 | pub fn (app mut App) serve_static(static_prefix string, static_root string) {
| ~~~~~~~~~~~~~
154 | // app.serve_static('/static/', './static/')
155 | mut prefix := static_prefix
/Users/huanghe/.vmodules/valval/valval.v:399:10: warning: use e.g. x := [1]Type{} instead of x := [1]Type
397 | mut total_size := 0
398 | for {
399 | buf := [1024]byte
| ~~~~~~~~~~
400 | if debug {
401 | println('recv..')
/Users/huanghe/.vmodules/valval/valval.v:59:17: warning: unnecessary default value of '': struct fields are zeroed by default
57 | pub mut:
58 | status int = 200
59 | body string = ''
| ~~
60 | content_type string = 'text/html; charset=utf-8'
61 | headers map[string]string
/Users/huanghe/.vmodules/valval/valval.v:136:16: warning: unnecessary default value of 0: struct fields are zeroed by default
134 | name string = 'ValvalApp'
135 | debug bool = true
136 | run_ts int = 0
| ^
137 | mut:
138 | router map[string]Handler
/Users/huanghe/.vmodules/valval/valval.v:330:11: warning: method strings.Builder.free must be called from an unsafe block
328 | }
329 | }
330 | builder.free()
| ~~~~~~
331 |
332 | conn.send_string(res.body) or {}
/Users/huanghe/.vmodules/valval/valval.v:418:9: warning: function tos_clone must be called from an unsafe block
416 | return error('413')
417 | }
418 | ss := tos_clone(bs)
| ~~~~~~~~~~~~~
419 | message += ss
420 | if n == m {
/Users/huanghe/.vmodules/valval/valval.v:196:16: error: cannot copy map: call move or clone method (or use a reference)
194 |
195 | fn (app App) find_handler(req Request) Handler {
196 | router := app.router
| ~~~~~~
197 | path := req.path.trim_right('/')
198 | method_path := '${req.method}:$path'
/Users/huanghe/.vmodules/valval/valval.v:200:2: error: unnecessary () in if condition, use if expr { instead of if (expr) {.
198 | method_path := '${req.method}:$path'
199 | // first match method:path
200 | if (method_path in router) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
201 | return router[method_path]
202 | }
/Users/huanghe/.vmodules/valval/valval.v:204:2: error: unnecessary () in if condition, use if expr { instead of if (expr) {.
202 | }
203 | // then math path
204 | if (path in router) {
| ~~~~~~~~~~~~~~~~~~~
205 | return router[path]
206 | }
/Users/huanghe/.vmodules/valval/valval.v:233:22: error: unknown function: net.listen
231 | // listener := net.listen(server.port) or { panic('failed to listen') }
232 | for {
233 | listener := net.listen(server.port) or { panic('failed to listen') }
| ~~~~~~~~~~~~~~~~~~~
234 | conn := listener.accept() or { panic('accept failed') }
235 | listener.close() or {} // todo: do not close listener and recreate it everytime
/Users/huanghe/.vmodules/valval/valval.v:234:29: error: unexpected or block, the function accept does not return an optional
232 | for {
233 | listener := net.listen(server.port) or { panic('failed to listen') }
234 | conn := listener.accept() or { panic('accept failed') }
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235 | listener.close() or {} // todo: do not close listener and recreate it everytime
236 | if app.debug {
/Users/huanghe/.vmodules/valval/valval.v:235:20: error: unexpected or block, the function close does not return an optional
233 | listener := net.listen(server.port) or { panic('failed to listen') }
234 | conn := listener.accept() or { panic('accept failed') }
235 | listener.close() or {} // todo: do not close listener and recreate it everytime
| ~~~~~
236 | if app.debug {
237 | println('===============')
/Users/huanghe/.vmodules/valval/valval.v:240:22: error: cannot use void as net.Socket in argument 1 to readall
238 | println(conn)
239 | }
240 | message := readall(conn, app.debug) or {
| ~~~~
241 | println(err)
242 | if err == '413' {
/Users/huanghe/.vmodules/valval/valval.v:243:26: error: unexpected or block, the function write does not return an optional
241 | println(err)
242 | if err == '413' {
243 | conn.write(HTTP_413) or {}
| ~~~~~
244 | } else {
245 | conn.write(HTTP_500) or {}
/Users/huanghe/.vmodules/valval/valval.v:245:26: error: unexpected or block, the function write does not return an optional
243 | conn.write(HTTP_413) or {}
244 | } else {
245 | conn.write(HTTP_500) or {}
| ~~~~~
246 | }
247 | conn.close() or {}
/Users/huanghe/.vmodules/valval/valval.v:247:17: error: unexpected or block, the function close does not return an optional
245 | conn.write(HTTP_500) or {}
246 | }
247 | conn.close() or {}
| ~~~~~
248 | continue
249 | }
/Users/huanghe/.vmodules/valval/valval.v:257:25: error: unexpected or block, the function write does not return an optional
255 | if lines.len < 2 {
256 | println('invalid message for http')
257 | conn.write(HTTP_500) or {}
| ~~~~~
258 | conn.close() or {}
259 | continue
/Users/huanghe/.vmodules/valval/valval.v:258:17: error: unexpected or block, the function close does not return an optional
256 | println('invalid message for http')
257 | conn.write(HTTP_500) or {}
258 | conn.close() or {}
| ~~~~~
259 | continue
260 | }
/Users/huanghe/.vmodules/valval/valval.v:265:25: error: unexpected or block, the function write does not return an optional
263 | if items.len < 2 {
264 | println('invalid data for http')
265 | conn.write(HTTP_500) or {}
| ~~~~~
266 | conn.close() or {}
267 | continue
/Users/huanghe/.vmodules/valval/valval.v:266:17: error: unexpected or block, the function close does not return an optional
264 | println('invalid data for http')
265 | conn.write(HTTP_500) or {}
266 | conn.close() or {}
| ~~~~~
267 | continue
268 | }
/Users/huanghe/.vmodules/valval/valval.v:321:28: error: unexpected or block, the function send_string does not return an optional
319 |
320 | result := builder.str()
321 | conn.send_string(result) or {}
| ~~~~~
322 | if app.debug {
323 | println('------ response headers ------')
/Users/huanghe/.vmodules/valval/valval.v:332:30: error: unexpected or block, the function send_string does not return an optional
330 | builder.free()
331 |
332 | conn.send_string(res.body) or {}
| ~~~~~
333 | if app.debug {
334 | println('------- response body -----')
/Users/huanghe/.vmodules/valval/valval.v:342:16: error: unexpected or block, the function close does not return an optional
340 | }
341 |
342 | conn.close() or {}
| ~~~~~
343 |
344 | if app.debug {
/Users/huanghe/.vmodules/valval/valval.v:395:1: error: unknown type net.Socket.
Did you mean net.SocketType?
393 | }
394 |
395 | fn readall(conn net.Socket, debug bool) ?string {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396 | mut message := ''
397 | mut total_size := 0
/Users/huanghe/.vmodules/valval/valval.v:410:17: error: unknown method: net.Socket.recv
408 | break
409 | }
410 | bs, m := conn.recv(1024 - 1)
| ~~~~~~~~~~~~~~
411 | total_size += m
412 | if debug {
/Users/huanghe/.vmodules/valval/valval.v:411:17: error: invalid right operand: int += void
409 | }
410 | bs, m := conn.recv(1024 - 1)
411 | total_size += m
| ^
412 | if debug {
413 | println('m: $m, total: $total_size')
/Users/huanghe/.vmodules/valval/valval.v:418:19: error: cannot use void as byteptr in argument 1 to tos_clone
416 | return error('413')
417 | }
418 | ss := tos_clone(bs)
| ~~
419 | message += ss
420 | if n == m {
/Users/huanghe/.vmodules/valval/valval.v:420:6: error: non-bool type void used as if condition
418 | ss := tos_clone(bs)
419 | message += ss
420 | if n == m {
| ~~~~~~
421 | break
422 | }
/Users/huanghe/.vmodules/valval/valval.v:429:27: error: cannot assign to field run_ts: expected int, not u64
427 | pub fn new_app(debug bool) App {
428 | run_ts := time.now().unix
429 | return App{debug: debug, run_ts: run_ts}
| ~~~~~~~~~~~~~~
430 | }
431 |
/Users/huanghe/.vmodules/valval/valval.v:532:6: error: os.write_file() returns an option, so it should have either an or {} block, or ? at the end
530 | bottom += ''
531 | content = content.replace_once('', bottom)
532 | os.write_file(template2, content)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
533 | }
534 | view := View{
/Users/huanghe/.vmodules/valval/valval.v:588:12: error: unknown function: os.ext
586 | return response_bad('$path read_file failed')
587 | }
588 | ext := os.ext(path)
| ~~~~~~~~~
589 | mime_map := {
590 | '.css': 'text/css; charset=utf-8',
/Users/huanghe/.vmodules/valval/valval.v:602:26: error: invalid key: expected string, not void
600 | '.xml': 'text/xml; charset=utf-8'
601 | }
602 | content_type := mime_map[ext]
| ~~~~~
603 | res := Response {
604 | status: 200

@joao2391
Copy link

joao2391 commented May 15, 2021

@dvwallin , I've got the same error as @huangrice
I'm using Linux Mint version 20 (Ulyana)

V version:
V 0.2.2 1305ca6

@DavidSatimeWallin
Copy link
Collaborator

Yeah valval is completely broken for V version 0.2+
There will be fixes for this but they've been slightly delayed.
Will probably spend todays stream working further on valval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants