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

C error found - error: undefined symbol 'Array_main__Student_ptr_delete_last' #21418

Closed
forchid opened this issue May 4, 2024 · 0 comments · Fixed by #21439
Closed

C error found - error: undefined symbol 'Array_main__Student_ptr_delete_last' #21418

forchid opened this issue May 4, 2024 · 0 comments · Fixed by #21439
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@forchid
Copy link

forchid commented May 4, 2024

Describe the bug

>v run arraylist.v
==================
C:/Users/Administrator/AppData/Local/Temp/v_0/arraylist.01HX1ZMCE4R7HN551RZ3PP872S.tmp.c:13222: warning: implicit declaration of function 'Array_main__Student_ptr_delete_last'
tcc: error: undefined symbol 'Array_main__Student_ptr_delete_last'
...
==================
(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 .

Reproduction Steps

V source code

struct ArrayList<T> {
  mut:
  size usize
  items []T
}

fn new_array_list[T]() ArrayList<T> {
  return ArrayList<T>{}
}

fn (li ArrayList<T>) is_empty() bool {
  return li.size == 0
}

fn (mut li ArrayList<T>) add(item T) {
  li.items << item
  li.size += 1
}

fn (mut li ArrayList<T>) pop() ?T {
  if li.is_empty() {
    return none
  } else {
    item := li.items.last()
    li.items.delete_last()
    li.size -= 1
    return item
  }
}

struct Student {
  name string
  mut:
  age u8
}

fn (mut s Student) grow() {
  s.age += 1
}

fn main() {
  mut list := new_array_list<&Student>()
  assert list.is_empty() && list.size == 0
  
  mut stu := &Student{'Tom', 16 }
  list.add(stu)
  assert !list.is_empty() && list.size == 1
  stu.grow()
  assert stu.age == 17
  
  tom := list.pop()?
  assert list.is_empty() && list.size == 0
  assert tom == stu && tom.age == 17
  
  println('ok.')
}

Run it

>v run arraylist.v

Expected Behavior

Run it normally.

Current Behavior

error: undefined symbol 'Array_main__Student_ptr_delete_last'

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.5 0459519

Environment details (OS name and version, etc.)

>v doctor
V full version: V 0.4.5 937a36a.0459519
OS: windows, Microsoft Windows 10 רҵ v19042 64 λ
Processor: 4 cpus, 64bit, little endian,

getwd: D:\code\lang\vlang\ds
vexe: D:\Programs\v\v.exe
vexe mtime: 2024-05-02 06:28:06

vroot: OK, value: D:\Programs\v
VMODULES: OK, value: C:\Users\Administrator\.vmodules
VTMP: OK, value: C:\Users\Administrator\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

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.

@forchid forchid added the Bug This tag is applied to issues which reports bugs. label May 4, 2024
@felipensp felipensp added the Unit: cgen Bugs/feature requests, that are related to the default C generating backend. label May 5, 2024
@felipensp felipensp self-assigned this May 5, 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. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants