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

[BUG] LLVM ERROR: Failed to infer result type(s). #3481

Open
andrew-suprun opened this issue Sep 14, 2024 · 0 comments
Open

[BUG] LLVM ERROR: Failed to infer result type(s). #3481

andrew-suprun opened this issue Sep 14, 2024 · 0 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@andrew-suprun
Copy link

Bug description

The compiler failed to compile the script that, probably, it should.

Steps to reproduce

The script:

from collections import Optional


@value
struct Node:
    var child: Optional[Node]


fn main():
    _ = Optional(Node(None)).value()

The stack trace:

/Users/andrewsuprun/dev/mojo/hello-world/hello.mojo:5:8: error: expected struct operand
struct Node:
       ^
LLVM ERROR: Failed to infer result type(s).
Please submit a bug report to https://github.com/modularml/mojo/issues and include the crash backtrace along with all the relevant source codes.
 #0 0x0000000103a89fcc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x103495fcc)
 #1 0x0000000103a8829c llvm::sys::RunSignalHandlers() (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x10349429c)
 #2 0x0000000103a8a66c SignalHandler(int) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x10349666c)
 #3 0x000000019feaa584 (/usr/lib/system/libsystem_platform.dylib+0x18047a584)
 #4 0x000000019fe79c20 (/usr/lib/system/libsystem_pthread.dylib+0x180449c20)
 #5 0x000000019fd86a30 (/usr/lib/system/libsystem_c.dylib+0x180356a30)
 #6 0x0000000103a59430 llvm::report_fatal_error(llvm::Twine const&, bool) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x103465430)
 #7 0x0000000103a59268 llvm::report_fatal_error(llvm::Twine const&, bool) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x103465268)
 #8 0x0000000100b3281c M::KGEN::StructGEPOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::Value, unsigned int) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x10053e81c)
 #9 0x00000001007e8934 M::KGEN::StructGEPOp mlir::OpBuilder::create<M::KGEN::StructGEPOp, mlir::Value, int&>(mlir::Location, mlir::Value&&, int&) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1001f4934)
#10 0x00000001007e8878 lowerOp(M::KGEN::LIT::RefStructGEROp, M::KGEN::LIT::RefStructGEROpAdaptor, (anonymous namespace)::LITTypeLowerer&) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1001f4878)
#11 0x00000001007e67ec (anonymous namespace)::LowerLITTypesPass::runOnOperation()::$_25::operator()(mlir::Operation*) const (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1001f27ec)
#12 0x000000010069c850 mlir::WalkResult mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<mlir::WalkResult (mlir::Operation*)>, mlir::WalkOrder) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1000a8850)
#13 0x000000010069c850 mlir::WalkResult mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<mlir::WalkResult (mlir::Operation*)>, mlir::WalkOrder) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1000a8850)
#14 0x00000001007e2448 (anonymous namespace)::LowerLITTypesPass::runOnOperation() (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1001ee448)
#15 0x00000001036af388 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1030bb388)
#16 0x00000001036b24e0 mlir::PassManager::run(mlir::Operation*) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1030be4e0)
#17 0x0000000100bc22cc void llvm::detail::UniqueFunctionBase<void, M::AsyncRT::AnyAsyncValueRef&&>::CallImpl<M::Cache::cachedTransform(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, mlir::PassManager&, std::__1::function<void (mlir::Operation*)> const&, std::__1::function<void (mlir::Operation*)> const&)::$_0::operator()(mlir::Operation*, M::RCRef<M::WriteableBuffer>, M::AsyncRT::AnyAsyncValueRef) const::'lambda'(M::AsyncRT::AnyAsyncValueRef&&)>(void*, M::AsyncRT::AnyAsyncValueRef&) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1005ce2cc)
#18 0x000000010074a5fc void M::AsyncRT::AnyAsyncValueRef::andThen<false>(llvm::unique_function<void (M::AsyncRT::AnyAsyncValueRef&&)>&&) && (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1001565fc)
#19 0x0000000100bc1e74 M::AsyncRT::AnyAsyncValueRef llvm::detail::UniqueFunctionBase<M::AsyncRT::AnyAsyncValueRef, M::RCRef<M::WriteableBuffer>, M::AsyncRT::AnyAsyncValueRef>::CallImpl<M::AsyncRT::AnyAsyncValueRef M::Cache::cachedTransform<M::Cache::cachedTransform(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, mlir::PassManager&, std::__1::function<void (mlir::Operation*)> const&, std::__1::function<void (mlir::Operation*)> const&)::$_0, M::Cache::cachedTransform(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, mlir::PassManager&, std::__1::function<void (mlir::Operation*)> const&, std::__1::function<void (mlir::Operation*)> const&)::$_1>(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, M::RCRef<M::WriteableBuffer>, M::Cache::cachedTransform(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, mlir::PassManager&, std::__1::function<void (mlir::Operation*)> const&, std::__1::function<void (mlir::Operation*)> const&)::$_0&&, M::Cache::cachedTransform(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, mlir::PassManager&, std::__1::function<void (mlir::Operation*)> const&, std::__1::function<void (mlir::Operation*)> const&)::$_1&&)::'lambda'(M::RCRef<M::WriteableBuffer>, M::AsyncRT::AnyAsyncValueRef)>(void*, M::RCRef<M::WriteableBuffer>&, M::AsyncRT::AnyAsyncValueRef&) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1005cde74)
#20 0x0000000100bc195c void llvm::detail::UniqueFunctionBase<void, M::AsyncRT::AsyncValueRef<std::__1::optional<M::RCRef<M::Buffer>>>&&>::CallImpl<M::AsyncRT::AnyAsyncValueRef M::Cache::cachedTransform<M::AsyncRT::AnyAsyncValueRef M::Cache::cachedTransform<M::Cache::cachedTransform(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, mlir::PassManager&, std::__1::function<void (mlir::Operation*)> const&, std::__1::function<void (mlir::Operation*)> const&)::$_0, M::Cache::cachedTransform(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, mlir::PassManager&, std::__1::function<void (mlir::Operation*)> const&, std::__1::function<void (mlir::Operation*)> const&)::$_1>(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, M::RCRef<M::WriteableBuffer>, M::Cache::cachedTransform(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, mlir::PassManager&, std::__1::function<void (mlir::Operation*)> const&, std::__1::function<void (mlir::Operation*)> const&)::$_0&&, M::Cache::cachedTransform(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, mlir::PassManager&, std::__1::function<void (mlir::Operation*)> const&, std::__1::function<void (mlir::Operation*)> const&)::$_1&&)::'lambda'(M::RCRef<M::WriteableBuffer>, M::AsyncRT::AnyAsyncValueRef)>(M::AsyncRT::EncodedLocation, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>> const&, M::AsyncRT::AnyAsyncValueRef, M::RCRef<M::WriteableBuffer>, M::Cache::cachedTransform(mlir::Operation*, M::RCRef<M::Cache::BlobCache<M::Cache::TransformCacheKey>>, M::AsyncRT::AnyAsyncValueRef, mlir::PassManager&, std::__1::function<void (mlir::Operation*)> const&, std::__1::function<void (mlir::Operation*)> const&)::$_0, llvm::unique_function<M::AsyncRT::AnyAsyncValueRef (M::RCRef<M::Buffer>)>, bool)::'lambda'(M::AsyncRT::AsyncValueRef<std::__1::optional<M::RCRef<M::Buffer>>>&&)>(void*, M::AsyncRT::AsyncValueRef<std::__1::optional<M::RCRef<M::Buffer>>>&) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1005cd95c)
#21 0x0000000100bcaffc void (anonymous namespace)::WorkQueueThread::runItemsImpl<(anonymous namespace)::WorkQueueThread::runOnThread()::$_0, (anonymous namespace)::WorkQueueThread::runOnThread()::$_1>((anonymous namespace)::WorkQueueThread::runOnThread()::$_0, (anonymous namespace)::WorkQueueThread::runOnThread()::$_1, bool, llvm::StringLiteral, llvm::StringLiteral) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1005d6ffc)
#22 0x0000000100bcae38 (anonymous namespace)::WorkQueueThread::runOnThread() (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1005d6e38)
#23 0x0000000100bcaed4 void* std::__1::__thread_proxy[abi:un170006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void ((anonymous namespace)::WorkQueueThread::*)(), (anonymous namespace)::WorkQueueThread*>>(void*) (/Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/bin/mojo+0x1005d6ed4)
#24 0x000000019fe79f94 (/usr/lib/system/libsystem_pthread.dylib+0x180449f94)
#25 0x000000019fe74d34 (/usr/lib/system/libsystem_pthread.dylib+0x180444d34)
mojo crashed!
Please file a bug report.
[48498:9033344:20240914,014433.092014:ERROR directory_reader_posix.cc:42] opendir /Users/andrewsuprun/dev/mojo/hello-world/.magic/envs/default/share/max/crashdb/attachments/5a39841f-c8cb-4b61-b7ac-2eb3bdb70304: No such file or directory (2)
[48498:9033343:20240914,014433.104073:WARNING crash_report_exception_handler.cc:257] UniversalExceptionRaise: (os/kern) failure (5)
[1```

### System information

```shell
MacOS Sonoma 14.6.1
mojo 24.5.0 (e8aacb95)
magic 0.2.3
@andrew-suprun andrew-suprun added bug Something isn't working mojo-repo Tag all issues with this label labels Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

1 participant