You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems there is a reminiscence about syntax for script mode. Next code in the playground:
x='v'structStr { }
produces the message:
Running code...
Can't run code. The server returned an error:
code.v:1:1: notice: script mode started here
1 | x = 'v'
| ^
2 | struct Str { }
code.v:2:8: error: all definitions must occur before code in script mode
1 | x = 'v'
2 | struct Str { }
| ~~~
Exited with error status 1
Please try again.
If we move the struct before the x then the compiler request to change the syntax:
undefined ident: `x` (use `:=` to declare a variable)
The REPL also enforces the syntax:
\ \ / / | Welcome to the V REPL (for help with V itself, typeexit , then run v help ).
\ \/ / | Note: the REPL is highly experimental. For best V experience, use a text editor,
\ / | save your code in a main.v file and execute: v run main.v
\ / | V 0.4.9 7078a2e . Use list to see the accumulated program so far.
\__/ | Use Ctrl-C or exit to exit, or help to see other available commands.
>>> x = 'v'
error: undefined ident: `x` (use `:=` to declare a variable)
5 | import math
6 |
7 | x = 'v'| ^
>>> x := 'v'
>>>
Describe the bug
Reproduction Steps
Expected Behavior
The compiler should warn about the variable declaration being incomplete.
Current Behavior
The compiler errors out with a wrong explanation.
Possible Solution
No response
Additional Information/Context
No response
V version
0.4.9
Environment details (OS name and version, etc.)
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.
Huly®: V_0.6-21827
The text was updated successfully, but these errors were encountered: