Giter VIP home page Giter VIP logo

Comments (1)

forchid avatar forchid commented on September 25, 2024 3

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.