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
V full version: V 0.4.6 8215f21.0fe2d60
OS: macos, macOS, 14.4.1, 23E224
Processor: 8 cpus, 64bit, little endian, Apple M2
getwd: /Users/mike/Documents/github/coreutils/src/cut
vexe: /Users/mike/Documents/github/v/v
vexe mtime: 2024-05-23 15:47:14
vroot: OK, value: /Users/mike/Documents/github/v
VMODULES: OK, value: /Users/mike/.vmodules
VTMP: OK, value: /tmp/v_501
Git version: git version 2.45.0
Git vroot status: 0.4.6-25-g0fe2d605
.git/config present: true
CC version: Apple clang version 15.0.0 (clang-1500.3.9.4)
thirdparty/tcc status: thirdparty-macos-arm64 5c1d002f
Checked marked issue in https://github.com/mike-ward/coreutils at 6d2896f
adding line 67: bytes: get_range(bytes) or { common.exit_with_error_message(app_name, err.msg()) }
caused the issue.
What did you do? v -g -o vdbg cmd/v && vdbg cut.v
See attached file cut.v
What did you expect to see?
Successful compilation
What did you see instead?
cut.v:41:2: warning: unused variable: `characters`
39 |
40 | bytes := fp.string('bytes', `b`, '', 'select only <string> range of bytes')
41 | characters := fp.string('characters', `c`, '', 'select only <string> range of characters')
| ~~~~~~~~~~
42 | delimiter := fp.string('delimter', `d`, '', 'use <string> instead of TAB for field delimter')
43 | fields := fp.string('fields', `f`, '',
cut.v:42:2: warning: unused variable: `delimiter`
40 | bytes := fp.string('bytes', `b`, '', 'select only <string> range of bytes')
41 | characters := fp.string('characters', `c`, '', 'select only <string> range of characters')
42 | delimiter := fp.string('delimter', `d`, '', 'use <string> instead of TAB for field delimter')
| ~~~~~~~~~
43 | fields := fp.string('fields', `f`, '',
44 | 'select only <string> fields; also print any line${wrap}' +
cut.v:43:2: warning: unused variable: `fields`
41 | characters := fp.string('characters', `c`, '', 'select only <string> range of characters')
42 | delimiter := fp.string('delimter', `d`, '', 'use <string> instead of TAB for field delimter')
43 | fields := fp.string('fields', `f`, '',
| ~~~~~~
44 | 'select only <string> fields; also print any line${wrap}' +
45 | 'that contains no delimiter character, unless the${wrap}-s option is specified')
cut.v:47:2: warning: unused variable: `only_delimited`
45 | 'that contains no delimiter character, unless the${wrap}-s option is specified')
46 | fp.bool('', `n`, false, '(ignored)')
47 | only_delimited := fp.bool('only-delimited', `s`, false, 'do not print lines not containing delimiters')
| ~~~~~~~~~~~~~~
48 | zero_terminated := fp.bool('zero-terminated', `z`, false, 'line delimiter is NUL, not newline')
49 | complement := fp.string('complement', ` `, '', 'complement the set of selected bytes, characters${wrap}or fields')
cut.v:48:2: warning: unused variable: `zero_terminated`
46 | fp.bool('', `n`, false, '(ignored)')
47 | only_delimited := fp.bool('only-delimited', `s`, false, 'do not print lines not containing delimiters')
48 | zero_terminated := fp.bool('zero-terminated', `z`, false, 'line delimiter is NUL, not newline')
| ~~~~~~~~~~~~~~~
49 | complement := fp.string('complement', ` `, '', 'complement the set of selected bytes, characters${wrap}or fields')
50 | output_delimiter := fp.string('output-delimiter', ` `, '', 'use <string> as the output delimiter, default is${wrap}input delimiter')
cut.v:49:2: warning: unused variable: `complement`
47 | only_delimited := fp.bool('only-delimited', `s`, false, 'do not print lines not containing delimiters')
48 | zero_terminated := fp.bool('zero-terminated', `z`, false, 'line delimiter is NUL, not newline')
49 | complement := fp.string('complement', ` `, '', 'complement the set of selected bytes, characters${wrap}or fields')
| ~~~~~~~~~~
50 | output_delimiter := fp.string('output-delimiter', ` `, '', 'use <string> as the output delimiter, default is${wrap}input delimiter')
51 |
cut.v:50:2: warning: unused variable: `output_delimiter`
48 | zero_terminated := fp.bool('zero-terminated', `z`, false, 'line delimiter is NUL, not newline')
49 | complement := fp.string('complement', ` `, '', 'complement the set of selected bytes, characters${wrap}or fields')
50 | output_delimiter := fp.string('output-delimiter', ` `, '', 'use <string> as the output delimiter, default is${wrap}input delimiter')
| ~~~~~~~~~~~~~~~~
51 |
52 | help := fp.bool('help', 0, false, 'display this help')
==================
^
/tmp/v_501/cut.01HYK261MAMS2PM3F22RWEGPV5.tmp.c:20756:44: error: incompatible pointer to integer conversion initializing 'int' with an expression of type 'Array_fixed_int_2' (aka 'int[2]') [-Wint-conversion]
main__Args _t2 = ((main__Args){.bytes = (*(Array_fixed_int_2*)_t3.data),.character = {0, 0},.file_args = file_args,});
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6 warnings and 1 error generated.
...
==================
(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 .
cut.v
// Cut - extract sections from each line of input
import common
import flag
import os
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 {
mut fp := common.flag_parser(os.args)
eol := common.eol()
wrap := eol + flag.space
fp.application(app_name)
fp.description('Print selected parts of lines from each FILE to standard output.${eol}')
fp.description('With no FILE, or when FILE is -, read standard input.${eol}')
fp.description('Use one, and only one of -b, -c or -f. Each LIST is made up of one${eol}' +
'range, or many ranges separated by commas. Selected input is written${eol}' +
'in the same order that it is read, and is written exactly once.${eol}${eol}' +
'Each range is one of:${eol}${eol}' +
' N N\'th byte, character or field, counted from 1${eol}' +
' N- from N\'th byte, character or field, to end of line${eol}' +
' N-M from N\'th to M\'th (included) byte, character or field${eol}' +
' -M from first to M\'th (included) byte, character or field${eol}')
bytes := fp.string('bytes', `b`, '', 'select only <string> range of bytes')
characters := fp.string('characters', `c`, '', 'select only <string> range of characters')
delimiter := fp.string('delimter', `d`, '', 'use <string> instead of TAB for field delimter')
fields := fp.string('fields', `f`, '',
'select only <string> fields; also print any line${wrap}' +
'that contains no delimiter character, unless the${wrap}-s option is specified')
fp.bool('', `n`, false, '(ignored)')
only_delimited := fp.bool('only-delimited', `s`, false, 'do not print lines not containing delimiters')
zero_terminated := fp.bool('zero-terminated', `z`, false, 'line delimiter is NUL, not newline')
complement := fp.string('complement', ` `, '', 'complement the set of selected bytes, characters${wrap}or fields')
output_delimiter := fp.string('output-delimiter', ` `, '', 'use <string> as the output delimiter, default is${wrap}input delimiter')
help := fp.bool('help', 0, false, 'display this help')
version := fp.bool('version', 0, false, 'output version information')
file_args := fp.finalize() or { common.exit_with_error_message(app_name, err.msg()) }
if help {
success_exit(fp.usage())
}
if version {
success_exit('${app_name} ${common.coreutils_version()}')
}
// translate args
return Args{
bytes: get_range(bytes) or { common.exit_with_error_message(app_name, err.msg()) }
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]!
}
@[noreturn]
fn success_exit(messages ...string) {
for message in messages {
println(message)
}
exit(0)
}
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.
The text was updated successfully, but these errors were encountered:
// Cut - extract sections from each line of inputconstapp_name='cut'structArgs {
bytes [2]int
character [2]int
file_args []string
}
fnmain() {
make_args()
}
fncut(lines []string, arg Args) []string {
return []string{}
}
fnmake_args() Args {
// translate argsbytes:='-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 onlyfnget_range(arg string) ![2]int {
mutidx:=0muts:=''mute:=''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 }
ifidx== arg.len && start !=-1 {
return [start, 0]!
}
if arg[idx] !=`-` {
returnerror(err_msg)
}
idx +=1for idx < arg.len && arg[idx].is_digit() {
e += arg[idx].ascii_str()
idx +=1
}
if idx != arg.len {
returnerror(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
V doctor:
What did you do?
v -g -o vdbg cmd/v && vdbg cut.v
See attached file
cut.v
What did you expect to see?
Successful compilation
What did you see instead?
cut.v
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.
The text was updated successfully, but these errors were encountered: