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

The return stack pointer does not report an error #22726

Open
get200 opened this issue Nov 1, 2024 · 0 comments · May be fixed by #22756
Open

The return stack pointer does not report an error #22726

get200 opened this issue Nov 1, 2024 · 0 comments · May be fixed by #22756
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: Checker Bugs/feature requests, that are related to the type checker.

Comments

@get200
Copy link
Contributor

get200 commented Nov 1, 2024

Describe the bug

The return stack pointer does not report an error.

Reproduction Steps

module main

@[heap]
struct Student {
	name string
	age  int
}

fn main() {
	mut students := []Student{}
	students << Student{
		name: 'Mike'
		age:  16
	}
	students << Student{
		name: 'Amy'
		age:  15
	}

	amy := get_amy(students) or { unsafe { nil } }

	println('push and pop stack') // <-- just do some stack operations

	println(amy) // <-- wrong data
}

fn get_amy(students []Student) ?&Student {
	for s in students {
		if s.name == 'Amy' {
			return &s // <-- pointer to stack
		}
	}
	return none
}

output

PS E:\2024\v\demo> v run .
push and pop stack
&Student{
    name: 'push and pop stack'
    age: 15
}

Expected Behavior

An error should be reported when compiling.

Current Behavior

It compiles normally, but the running results are unpredictable.

Possible Solution

No response

Additional Information/Context

No response

V version

Current V version: V 0.4.8 fc6e481, timestamp: 2024-11-01 13:44:04 +0200

Environment details (OS name and version, etc.)

V full version: V 0.4.8 fc6e481
OS: windows, Microsoft Windows 11 v26120 64-bit
Processor: 24 cpus, 64bit, little endian,

getwd: D:\v\v
vexe: D:\v\v\v.exe
vexe mtime: 2024-11-01 13:27:00

vroot: OK, value: D:\v\v
VMODULES: OK, value: C:\Users\Administrator\.vmodules
VTMP: OK, value: C:\Users\Administrator\AppData\Local\Temp\v_0

Git version: git version 2.46.0.windows.1
Git vroot status: weekly.2024.41-183-gfc6e481b-dirty
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 b425ac82

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-21173

@get200 get200 added the Bug This tag is applied to issues which reports bugs. label Nov 1, 2024
@felipensp felipensp added Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: Checker Bugs/feature requests, that are related to the type checker. labels Nov 4, 2024
@felipensp felipensp self-assigned this Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: Checker Bugs/feature requests, that are related to the type checker.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants