mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[BUG]: Compiler crashes while analyzing function signature after variadic arguments

Open kishmakov opened this issue 11 months ago • 0 comments

Bug description

Either compiler or LSP crashes analyzing this:

fn test(first_args: Int, *second_args: Int, another_arg: Int = 1, other_arg: Int) -> Int:
  return another_arg

fn test2(first_args: Int, another_arg: Int = 1, *second_args: Int) -> Int:
  return another_arg

If it helps, here is the backtrace:

$ '/home/kishmakov/.modular/pkg/packages.modular.com_mojo/bin/mojo' '/home/kishmakov/Documents/mojo-examples/7.mojo'
/home/kishmakov/Documents/mojo-examples/7.mojo:1:67: error: required keyword-only argument follows optional keyword-only argument
fn test(first_args: Int, *second_args: Int, another_arg: Int = 1, other_arg: Int) -> Int:
                                                                  ^          ~~~
/home/kishmakov/Documents/mojo-examples/7.mojo:4:50: error: required positional argument follows optional positional argument
fn test2(first_args: Int, another_arg: Int = 1, *second_args: Int) -> Int:
                                                 ^            ~~~
<unknown>:0: error: variadic cannot have a default value
mojo: /__w/modular/modular/third-party/llvm-project/mlir/include/mlir/IR/StorageUniquerSupport.h:181: static ConcreteT mlir::detail::StorageUserBase<M::KGEN::LIT::PogsAttr, mlir::Attribute, M::KGEN::LIT::detail::PogsAttrStorage, mlir::detail::AttributeUniquer>::get(mlir::MLIRContext *, Args &&...) [ConcreteT = M::KGEN::LIT::PogsAttr, BaseT = mlir::Attribute, StorageT = M::KGEN::LIT::detail::PogsAttrStorage, UniquerT = mlir::detail::AttributeUniquer, Traits = <>, Args = <llvm::ArrayRef<mlir::StringAttr>, llvm::ArrayRef<M::KGEN::LIT::PassingKind>, llvm::ArrayRef<mlir::TypedAttr>, llvm::ArrayRef<mlir::TypedAttr>, llvm::ArrayRef<unsigned long>, llvm::ArrayRef<unsigned long>>]: Assertion `succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...))' failed.
Please submit a bug report to https://github.com/modularml/mojo/issues and include the crash backtrace along with all the relevant source codes.
Stack dump:
0.      Program arguments: /home/kishmakov/.modular/pkg/packages.modular.com_mojo/bin/mojo /home/kishmakov/Documents/mojo-examples/7.mojo
1.      Crash resolving decl signature at loc("/home/kishmakov/Documents/mojo-examples/7.mojo":4:1)
    >> fn test2(first_args: Int, another_arg: Int = 1, *second_args: Int) -> Int:
       ^.........................................................................<
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  mojo      0x00005593aa051e47
1  mojo      0x00005593aa04fa1e
2  mojo      0x00005593aa05251f
3  libc.so.6 0x00007f6e4fe42520
4  libc.so.6 0x00007f6e4fe969fc pthread_kill + 300
5  libc.so.6 0x00007f6e4fe42476 raise + 22
6  libc.so.6 0x00007f6e4fe287f3 abort + 211
7  libc.so.6 0x00007f6e4fe2871b
8  libc.so.6 0x00007f6e4fe39e96
9  mojo      0x00005593ab6ccd3d
10 mojo      0x00005593ab6c674f
11 mojo      0x00005593aa4e5646
12 mojo      0x00005593aa472709
13 mojo      0x00005593aa48d4ee
14 mojo      0x00005593aa48dfc8
15 mojo      0x00005593aa43bcfb
16 mojo      0x00005593aa43c059
17 mojo      0x00005593aa01830f
18 mojo      0x00005593a9ffd23b
19 mojo      0x00005593aa0175a0
20 mojo      0x00005593a9ff6873
21 libc.so.6 0x00007f6e4fe29d90
22 libc.so.6 0x00007f6e4fe29e40 __libc_start_main + 128
23 mojo      0x00005593a9ff5fae
Aborted (core dumped)

Steps to reproduce

Paste mentioned snippet in VS Code.

System information

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
Codename:	jammy
$ mojo --version
mojo 24.1.0 (55ec12d6)
$ modular -v
modular 0.5.1 (1b608e3d)

kishmakov avatar Mar 09 '24 08:03 kishmakov