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

js-backend can't compile life.v #20667

Open
Ameeer1 opened this issue Jan 26, 2024 · 0 comments
Open

js-backend can't compile life.v #20667

Ameeer1 opened this issue Jan 26, 2024 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs. Unit: JS Bugs/feature requests, that are related to the JavaScript backend.

Comments

@Ameeer1
Copy link
Contributor

Ameeer1 commented Jan 26, 2024

Describe the bug

when i try to compile life.v("examples\game_of_life\life.v") using("v -prod -b js -prod -o life.js life.v") i get an error

Reproduction Steps

C:\apps\v\examples\game_of_life>v -prod -b js -prod -o life.js life.v
C:/apps/v/vlib/term/utf8.v:5:7: error: unknown function: input_character
    3 | // utf8_getchar returns an utf8 rune from standard input
    4 | pub fn utf8_getchar() ?rune {
    5 |     c := input_character()
      |          ~~~~~~~~~~~~~~~~~
    6 |     if c == -1 {
    7 |         return none
C:/apps/v/vlib/term/utf8.v:5:4: error: assignment mismatch: 1 variable(s) but `input_character()` returns 0 value(s)
    3 | // utf8_getchar returns an utf8 rune from standard input
    4 | pub fn utf8_getchar() ?rune {
    5 |     c := input_character()
      |       ~~
    6 |     if c == -1 {
    7 |         return none
C:/apps/v/vlib/term/utf8.v:6:5: error: non-bool type `void` used as if condition
    4 | pub fn utf8_getchar() ?rune {
    5 |     c := input_character()
    6 |     if c == -1 {
      |        ~~~~~~~
    7 |         return none
    8 |     }
C:/apps/v/vlib/term/utf8.v:9:21: error: operator `~` can only be used with integer types, but the value after `~` is of type `void` instead
    7 |         return none
    8 |     }
    9 |     len := utf8_len(u8(~c))
      |                        ^
   10 |     if c < 0 {
   11 |         return 0
C:/apps/v/vlib/term/utf8.v:9:21: error: expression does not return a value so it cannot be cast
    7 |         return none
    8 |     }
    9 |     len := utf8_len(u8(~c))
      |                        ^
   10 |     if c < 0 {
   11 |         return 0
C:/apps/v/vlib/term/utf8.v:9:18: error: cannot cast type `void` to `u8`
    7 |         return none
    8 |     }
    9 |     len := utf8_len(u8(~c))
      |                     ~~~~~~
   10 |     if c < 0 {
   11 |         return 0
C:/apps/v/vlib/term/utf8.v:10:5: error: non-bool type `void` used as if condition
    8 |     }
    9 |     len := utf8_len(u8(~c))
   10 |     if c < 0 {
      |        ~~~~~
   11 |         return 0
   12 |     } else if len == 0 {
C:/apps/v/vlib/term/utf8.v:13:3: error: `c` used as value
   11 |         return 0
   12 |     } else if len == 0 {
   13 |         return c
      |         ~~~~~~~~
   14 |     } else if len == 1 {
   15 |         return -1
C:/apps/v/vlib/term/utf8.v:17:13: error: mismatched types `void` and `int literal`
   15 |         return -1
   16 |     } else {
   17 |         mut uc := c & ((1 << (7 - len)) - 1)
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |         for i := 0; i + 1 < len; i++ {
   19 |             c2 := input_character()
C:/apps/v/vlib/term/utf8.v:19:10: error: unknown function: input_character
   17 |         mut uc := c & ((1 << (7 - len)) - 1)
   18 |         for i := 0; i + 1 < len; i++ {
   19 |             c2 := input_character()
      |                   ~~~~~~~~~~~~~~~~~
   20 |             if c2 != -1 && (c2 >> 6) == 2 {
   21 |                 uc <<= 6
C:/apps/v/vlib/term/utf8.v:19:7: error: assignment mismatch: 1 variable(s) but `input_character()` returns 0 value(s)
   17 |         mut uc := c & ((1 << (7 - len)) - 1)
   18 |         for i := 0; i + 1 < len; i++ {
   19 |             c2 := input_character()
      |                ~~
   20 |             if c2 != -1 && (c2 >> 6) == 2 {
   21 |                 uc <<= 6
C:/apps/v/vlib/term/utf8.v:20:20: error: invalid operation: shift on type `void`
   18 |         for i := 0; i + 1 < len; i++ {
   19 |             c2 := input_character()
   20 |             if c2 != -1 && (c2 >> 6) == 2 {
      |                             ~~
   21 |                 uc <<= 6
   22 |                 uc |= (c2 & 63)
C:/apps/v/vlib/term/utf8.v:20:7: error: left operand for `&&` is not a boolean
   18 |         for i := 0; i + 1 < len; i++ {
   19 |             c2 := input_character()
   20 |             if c2 != -1 && (c2 >> 6) == 2 {
      |                ~~~~~~~~
   21 |                 uc <<= 6
   22 |                 uc |= (c2 & 63)
C:/apps/v/vlib/term/utf8.v:20:19: error: right operand for `&&` is not a boolean
   18 |         for i := 0; i + 1 < len; i++ {
   19 |             c2 := input_character()
   20 |             if c2 != -1 && (c2 >> 6) == 2 {
      |                            ~~~~~~~~~~~~~~
   21 |                 uc <<= 6
   22 |                 uc |= (c2 & 63)
C:/apps/v/vlib/term/utf8.v:20:7: error: non-bool type `void` used as if condition
   18 |         for i := 0; i + 1 < len; i++ {
   19 |             c2 := input_character()
   20 |             if c2 != -1 && (c2 >> 6) == 2 {
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~
   21 |                 uc <<= 6
   22 |                 uc |= (c2 & 63)
C:/apps/v/vlib/term/utf8.v:21:5: error: operator <<= not defined on left operand type `void`
   19 |             c2 := input_character()
   20 |             if c2 != -1 && (c2 >> 6) == 2 {
   21 |                 uc <<= 6
      |                 ~~
   22 |                 uc |= (c2 & 63)
   23 |             } else if c2 == -1 {
C:/apps/v/vlib/term/utf8.v:21:12: error: cannot assign to `uc`: expected `void`, not `int literal`
   19 |             c2 := input_character()
   20 |             if c2 != -1 && (c2 >> 6) == 2 {
   21 |                 uc <<= 6
      |                        ^
   22 |                 uc |= (c2 & 63)
   23 |             } else if c2 == -1 {
C:/apps/v/vlib/term/utf8.v:22:12: error: mismatched types `void` and `int literal`
   20 |             if c2 != -1 && (c2 >> 6) == 2 {
   21 |                 uc <<= 6
   22 |                 uc |= (c2 & 63)
      |                        ~~~~~~~
   23 |             } else if c2 == -1 {
   24 |                 return 0
C:/apps/v/vlib/term/utf8.v:23:14: error: non-bool type `void` used as if condition
   21 |                 uc <<= 6
   22 |                 uc |= (c2 & 63)
   23 |             } else if c2 == -1 {
      |                       ~~~~~~~~
   24 |                 return 0
   25 |             } else {
C:/apps/v/vlib/term/utf8.v:29:3: error: `uc` used as value
   27 |             }
   28 |         }
   29 |         return uc
      |         ~~~~~~~~~
   30 |     }
   31 | }
If the code of your project is in multiple files, try with `v .` instead of `v life.v`
If the code of your project is in multiple files, try with `v .` instead of `v life.v`

Expected Behavior

it should create life,js file

Current Behavior

v can't compile life.v file to life.js and return errors

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.4 4163faf

Environment details (OS name and version, etc.)

windows 11

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@Ameeer1 Ameeer1 added the Bug This tag is applied to issues which reports bugs. label Jan 26, 2024
@felipensp felipensp added the Unit: JS Bugs/feature requests, that are related to the JavaScript backend. label Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: JS Bugs/feature requests, that are related to the JavaScript backend.
Projects
None yet
Development

No branches or pull requests

2 participants