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

$dbg does not work everywhere #21772

Closed
thomas-mangin opened this issue Jun 30, 2024 · 0 comments · Fixed by #21747
Closed

$dbg does not work everywhere #21772

thomas-mangin opened this issue Jun 30, 2024 · 0 comments · Fixed by #21747
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@thomas-mangin
Copy link
Contributor

thomas-mangin commented Jun 30, 2024

Describe the bug

Using $dbg, I noticed that there is some places where it does lead to invalid code generation and/or compilation failure.

Reproduction Steps

module main

fn fails() ?int {
	return none
}

fn noop() {
	return
}

fn main() {
	a := fails() or {
		$dbg;
		noop()
		20
	}
	println('${a}')
}

Expected Behavior

The code to drop me into the debugger, like it does if moved outside the or {} block

Current Behavior

bad code generation:

> v -cg run bug.v
/tmp/v_501/bug.01J1MYCFGE9P3NE3YGCXC39MPJ.tmp.c:17280:4: warning: expression result unused [-Wunused-value]
  (*(int*)_t4.data);
   ^~~~~~~~~~~~~~~
/tmp/v_501/bug.01J1MYCFGE9P3NE3YGCXC39MPJ.tmp.c:17701:4: warning: expression result unused [-Wunused-value]
  (*(string*)_t1.data);
   ^~~~~~~~~~~~~~~~~~
/tmp/v_501/bug.01J1MYCFGE9P3NE3YGCXC39MPJ.tmp.c:19192:4: warning: expression result unused [-Wunused-value]
  (*(os__SignalHandler*)_t3.data);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v_501/bug.01J1MYCFGE9P3NE3YGCXC39MPJ.tmp.c:22709:5: warning: expression result unused [-Wunused-value]
                        (*(rune*)array_pop_noscan(&r->current));
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v_501/bug.01J1MYCFGE9P3NE3YGCXC39MPJ.tmp.c:22908:4: warning: expression result unused [-Wunused-value]
  (*(int*)_t1.data);
   ^~~~~~~~~~~~~~~
/tmp/v_501/bug.01J1MYCFGE9P3NE3YGCXC39MPJ.tmp.c:23420:58: warning: format specifies type 'int' but the argument has type 'i64' (aka 'long long') [-Wformat]
                printf("%s:%-4d | %s> %s\n", ((char*)(item.file.str)), item.line, string_repeat(_SLIT(" "), i).str, item.name);
                           ~~~~                                        ^~~~~~~~~
                           %-4lld
/tmp/v_501/bug.01J1MYCFGE9P3NE3YGCXC39MPJ.tmp.c:23420:103: warning: format specifies type 'char *' but the argument has type 'string' (aka 'struct string') [-Wformat]
                printf("%s:%-4d | %s> %s\n", ((char*)(item.file.str)), item.line, string_repeat(_SLIT(" "), i).str, item.name);
                                      ~~                                                                            ^~~~~~~~~
/tmp/v_501/bug.01J1MYCFGE9P3NE3YGCXC39MPJ.tmp.c:23769:121: error: use of undeclared identifier 'a'
                                _MOV((v__debug__DebugContextVar[2]){{.typ=_SLIT("IError"),.value=IError_str(err)},{.typ=_SLIT("int"),.value=int_str(a)}}));
                                                                                                                                                    ^
7 warnings and 1 error generated.
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 .

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.6 df7828d

Environment details (OS name and version, etc.)

V full version: V 0.4.6 cc14272.df7828d
OS: macos, macOS, 14.5, 23F79
Processor: 10 cpus, 64bit, little endian, Apple M1 Max

getwd: /Users/thomas/Code/github.com/ze-community/ze/main
vexe: /Users/thomas/Unix/local/v/master/v
vexe mtime: 2024-06-30 12:18:18

vroot: OK, value: /Users/thomas/Unix/local/v/master
VMODULES: OK, value: /Users/thomas/Unix/data/v/modules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.45.2
Git vroot status: weekly.2024.26-18-gdf7828d1-dirty
.git/config present: true

CC version: Apple clang version 15.0.0 (clang-1500.3.9.4)
thirdparty/tcc status: thirdparty-macos-arm64 5c1d002f

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.

@thomas-mangin thomas-mangin added the Bug This tag is applied to issues which reports bugs. label Jun 30, 2024
@felipensp felipensp self-assigned this Jul 1, 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants