SaptakBhoumik / Peregrine

A blazing fast language for the blazing fast world(WIP)
https://peregrine-lang.github.io/
Mozilla Public License 2.0
1.46k stars 76 forks source link

Error when compiling file #120

Closed InsaneMiner closed 2 years ago

InsaneMiner commented 2 years ago

Describe the bug when i compiled a simple file i got this error:

terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
zsh: abort (core dumped)  ./peregrine.elf test.pe

the code was:

def test()->int:
    printf("hello")
    return 1;

def main():
    test();

Desktop:

G++ info

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC)

meson info version: 0.61.1

gdb info

#0  0x00007ffff7bded22 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7bc8862 in abort () from /usr/lib/libc.so.6
#2  0x00007ffff7e22802 in __gnu_cxx::__verbose_terminate_handler () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x00007ffff7e2ec8a in __cxxabiv1::__terminate (handler=<optimized out>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#4  0x00007ffff7e2ecf7 in std::terminate () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#5  0x00007ffff7e2ef8e in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=0x7ffff7f91208 <typeinfo for std::out_of_range>, 
    dest=0x7ffff7e45010 <std::out_of_range::~out_of_range()>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95
#6  0x00007ffff7e25514 in std::__throw_out_of_range_fmt (__fmt=<optimized out>) at /build/gcc/src/gcc/libstdc++-v3/src/c++11/functexcept.cc:100
#7  0x000055555557463b in std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::_M_range_check (this=0x7fffffffaa50, __n=0) at /usr/include/c++/11.1.0/bits/stl_vector.h:1073
#8  0x00005555555734fd in std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::at (this=0x7fffffffaa50, __n=0) at /usr/include/c++/11.1.0/bits/stl_vector.h:1094
#9  0x00005555555666f6 in lexer (src="", filename="test.pe") at ../Peregrine/lexer/lexer.cpp:231
#10 0x0000555555560c28 in compile (s=...) at ../Peregrine/main.cpp:36
#11 0x00005555555618cb in main (argc=2, argv=0x7fffffffdde8) at ../Peregrine/main.cpp:70
SaptakBhoumik commented 2 years ago

@InsaneMiner You dont need the ; Use this

def test()->int:
    printf("hello")
    return 1

def main():
    test()
InsaneMiner commented 2 years ago

@InsaneMiner You dont need the ; Use this

def test()->int:
    printf("hello")
    return 1

def main():
    test()

that would not cause a that type of error