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] Mojo crashes on autoparameterized function parameter #2006

Closed
soraros opened this issue Mar 27, 2024 · 5 comments
Closed

[BUG] Mojo crashes on autoparameterized function parameter #2006

soraros opened this issue Mar 27, 2024 · 5 comments
Assignees
Labels
bug Something isn't working mojo Issues that are related to mojo mojo-repo Tag all issues with this label mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension.

Comments

@soraros
Copy link
Contributor

soraros commented Mar 27, 2024

Bug description

As title. __type_of also doesn't work. only the explicit from compiles.

Steps to reproduce

Either of the following crashes the compiler:

fn reduce[f: fn (x: Scalar) -> Scalar[x.type]]():
  ...

fn reduce[f: fn [dt: DType](x: Scalar[dt]) -> __type_of(x)]():
  ...

System information

Mojo 24.1.1 on Docker, Intel Mac
@soraros soraros added bug Something isn't working mojo Issues that are related to mojo labels Mar 27, 2024
@ematejska
Copy link
Collaborator

I don't see this failing with 24.2.

Here is the code I have:
fn reducef: fn [dt: DType](x: Scalar[dt]) -> __type_of(x):
pass

fn main():
print("hello")

@soraros Does this work for you with 24.2 and if not could you provide a fully formed example?

@soraros
Copy link
Contributor Author

soraros commented Apr 2, 2024

@ematejska I think now it only crashes the LSP, on both 24.2 and nightly. Notice that it is a full example.
Screenshot 2024-04-02 at 19 54 13

@soraros
Copy link
Contributor Author

soraros commented Apr 2, 2024

Actually, it's not crashing the LSP. Or at least the LSP itself isn't crashing. When you open a test.mojo with the above code snippet, the LSP is producing the following:

["INFO" - 6:09:45 PM] Activating language client for URI 'file:///workspaces/nightly/mojo-dev/stdlib/test.mojo'
I[18:09:45.429] --> textDocument/didOpen
D[18:09:45.429] --> textDocument/didOpen: uri='file:///workspaces/nightly/mojo-dev/stdlib/test.mojo', version=99
I[18:09:45.429] --> textDocument/documentSymbol(909)
I[18:09:45.429] --> textDocument/semanticTokens/full(910)
I[18:09:45.429] --> textDocument/codeAction(911)
E[18:09:45.439] Crash recovered: CrashRecoveryContext::RetCode (on POSIX: signal number + 128) = 139
E[18:09:45.439] A crash happened in the mojo parser when processing the file file:///workspaces/nightly/mojo-dev/stdlib/test.mojo.
Please report this issue in https://github.com/modularml/mojo/issues along with all the relevant source codes with the contents they had at crash time.
I[18:09:45.439] --> textDocument/publishDiagnostics
D[18:09:45.439] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"A crash happened in the mojo parser with the current version of this file. Please report this issue in https://github.com/modularml/mojo/issues along with all the relevant source codes with their current contents.","range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"severity":1,"source":"mojo"}],"uri":"file:///workspaces/nightly/mojo-dev/stdlib/test.mojo","version":99}}

@ematejska ematejska added the mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension. label Apr 4, 2024
@River707
Copy link
Collaborator

River707 commented Apr 5, 2024

Hmm, oof, we'll take a look! Thanks for the easy repro, makes it really easy to dig into this stuff

@River707 River707 self-assigned this Apr 12, 2024
@River707
Copy link
Collaborator

This should be fixed in the next release!

patrickdoc pushed a commit that referenced this issue May 2, 2024
…37596)

This PR adds proper support for signature types by synthesizing a
FunctionDeclView from a parsed signature type. This allows for tracking
references for named parameters/arguments in the signature type, and
also fixes various crashes around them. This functionality will be used
in a followup as a basis for supporting closures.

Fixes #1997
Fixes #2006
Fixes #2007
Fixes #37126

MODULAR_ORIG_COMMIT_REV_ID: b16ffac01d7bfb904e16da93731ed9e8f6016a77
@ematejska ematejska added the mojo-repo Tag all issues with this label label May 6, 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 Issues that are related to mojo mojo-repo Tag all issues with this label mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension.
Projects
None yet
Development

No branches or pull requests

3 participants