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

Error when building with autofree - ';' expected (got "_t2") #510

Open
ArtemkaKun opened this issue Mar 2, 2023 · 0 comments
Open

Error when building with autofree - ';' expected (got "_t2") #510

ArtemkaKun opened this issue Mar 2, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@ArtemkaKun
Copy link
Contributor

V doctor

OS: linux, "Garuda Linux"
Processor: 16 cpus, 64bit, little endian, AMD Ryzen 7 3800X 8-Core Processor
CC version: cc (GCC) 12.2.1 20230201

getwd: /home/yuart
vmodules: /home/yuart/.vmodules
vroot: /home/yuart/Projects/v
vexe: /home/yuart/Projects/v/v
vexe mtime: 2023-03-01 21:46:21
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.3 d971d93.e2daa84

Git version: git version 2.39.2
Git vroot status: weekly.2023.08-45-ge2daa84a
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

UI package version

cdf5216

System DE

DE: KDE Plasma 5.27.2
WM: KWin (Wayland)

What did you do?

Run the following code with v -autofree run .

import ui

[heap]
struct App {
mut:
	window ui.Window
	label  ui.Label
	model  Model
}

struct Model {
	counter_value int
}

enum Message {
	increment
	decrement
}

fn main() {
	mut app := App{}
	setup_app(mut app)

	ui.run(app.window)
}

fn setup_app(mut app App) {
	app.window = ui.window(
		width: 400
		height: 400
		title: 'MVU counter'
		children: [
			ui.column(
				margin: ui.Margin{50, 50, 50, 50}
				spacing: 5
				children: [
					app.label,
					ui.row(
						spacing: 5
						children: [
							ui.button(
								text: 'Increment'
								width: 100
								height: 50
								text_size: 20
								on_click: app.send_increment_signal
							),
							ui.button(
								text: 'Decrement'
								width: 100
								height: 50
								text_size: 20
								on_click: app.send_decrement_signal
							),
						]
					),
				]
			),
		]
	)

	app.label = ui.label(text: '0', text_size: 36)
}

fn (mut app App) send_increment_signal(_ &ui.Button) {
	app.model = update(Message.increment, app.model)
	app.react_on_model_change()
}

fn (mut app App) send_decrement_signal(_ &ui.Button) {
	app.model = update(Message.decrement, app.model)
	app.react_on_model_change()
}

fn update(message Message, current_model Model) Model {
	return match message {
		.increment {
			Model{
				counter_value: current_model.counter_value + 1
			}
		}
		.decrement {
			Model{
				counter_value: current_model.counter_value - 1
			}
		}
	}
}

fn (mut app App) react_on_model_change() {
	app.label.text = app.model.counter_value.str()
}

What did you expect to see?

The program started as expected and a window appeared.

What did you see instead

The following error

==================
/tmp/v_1000/ui_counter.17501532973111399599.tmp.c:45264: warning: assignment discards qualifiers from pointer target type
/tmp/v_1000/ui_counter.17501532973111399599.tmp.c:67549: error: ';' expected (got "_t2")
...
==================
(Use `v -cg` to print the entire error message)

builder error:
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang
@ArtemkaKun ArtemkaKun added the bug Something isn't working label Mar 2, 2023
@ArtemkaKun ArtemkaKun changed the title Autofree error - ';' expected (got "_t2") Autofree error - ';' expected (got "_t2") Mar 2, 2023
@ArtemkaKun ArtemkaKun changed the title Autofree error - ';' expected (got "_t2") Error when building with autofree - ';' expected (got "_t2") Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant