Comments (1)
A simple version of the issue test code
// Cut - extract sections from each line of input
const app_name = 'cut'
struct Args {
bytes [2]int
character [2]int
file_args []string
}
fn main() {
make_args()
}
fn cut(lines []string, arg Args) []string {
return []string{}
}
fn make_args() Args {
// translate args
bytes := '-a 1 -b';
file_args := ['a.txt', 'b.log'];
return Args{
bytes: get_range(bytes) or { panic('error!'); }
file_args: file_args
}
}
// range values interpreted as follows:
// [s>=0, e>0] simple range
// [s>=0, e==-1] from s to end of string
// [s>=0, e==0] s'th byte only
fn get_range(arg string) ![2]int {
mut idx := 0
mut s := ''
mut e := ''
err_msg := 'invalid range syntax (--help for more info)'
for idx < arg.len && arg[idx].is_digit() {
s += arg[idx].ascii_str()
idx += 1
}
start := if s.len > 0 { s.int() } else { 0 }
if idx == arg.len && start != -1 {
return [start, 0]!
}
if arg[idx] != `-` {
return error(err_msg)
}
idx += 1
for idx < arg.len && arg[idx].is_digit() {
e += arg[idx].ascii_str()
idx += 1
}
if idx != arg.len {
return error(err_msg)
}
end := if e.len > 0 { e.int() } else { -1 }
return [start, end]!
}
Do compile by using v 0.4.6
>v cut.v
.../AppData/Local/Temp/v_0/cut.01HYM4P03DXXPP9FCJQ8VQBNZP.tmp.c:13228: warning: cast between pointer and integer of different size
.../AppData/Local/Temp/v_0/cut.01HYM4P03DXXPP9FCJQ8VQBNZP.tmp.c:13228: error: struct/union type expected
...
==================
(Use `v -cg` to print the entire error message)
builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .
v doctor
>v doctor
V full version: V 0.4.6 c412b9f.736067d
OS: windows, Microsoft Windows 10 רҵ v19042 64 λ
Processor: 4 cpus, 64bit, little endian,
getwd: ...\vlang\bug
vexe: ...\v\v.exe
vexe mtime: 2024-05-20 18:12:48
vroot: OK, value: ...
VMODULES: OK, value: ...\.vmodules
VTMP: OK, value: ...\AppData\Local\Temp\v_0
Git version: git version 2.33.1.windows.1
Git vroot status: Error: fatal: not a git repository (or any of the parent directories): .git
.git/config present: false
CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.
thirdparty/tcc: N/A
from v.
Related Issues (20)
- io.BufferedWriter
- Introducing Internal Modules to V HOT 10
- V compiler fails to pass struct method to C
- Installing package from local git repository fails
- simple generic structure declaration error HOT 8
- modules.vlang.io tree links broken HOT 1
- WASM backend indexing issue
- passing a function to a function as a parameter does not work HOT 5
- cannot return a function from a generic function HOT 3
- docs: MD rendering issue on modules.vlang.io
- Optional explicit interface implementations HOT 12
- Allow to omit commas in multiline function signature block HOT 5
- https://vlang.io/ REPL example doesn't work HOT 1
- Provide easier installer like Rust HOT 5
- fmt: a regression was introduced in #22025 (vfmt struct init) HOT 3
- Precision format ignored in string interpolation HOT 4
- sum types should have a default 0 value for the first type mentioned in the list of types. HOT 4
- Passing a map to a generic argument changes a key value from int to an empty string HOT 1
- Module resolution depends on working directory HOT 3
- Free an optional structure HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v.