Skip to content

Typing related panic #5715

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

Open
arihant2math opened this issue Apr 19, 2025 · 2 comments
Open

Typing related panic #5715

arihant2math opened this issue Apr 19, 2025 · 2 comments
Labels
A-compiler Area: compiler C-bug Something isn't working

Comments

@arihant2math
Copy link
Collaborator

from collections import abc
type t = abc.Callable[[]]
thread 'main' panicked at compiler\codegen\src\ir.rs:247:66:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@arihant2math arihant2math added C-bug Something isn't working A-compiler Area: compiler labels Apr 19, 2025
@Undersk0re
Copy link
Contributor

Undersk0re commented Apr 29, 2025

it seems that ruff returns status ok with

from collections import abc
type x = abc.Callable[[]]

sending this ast

Module(
    ModModule {
        range: 0..56,
        body: [
            ImportFrom(
                StmtImportFrom {
                    range: 0..27,
                    module: Some(
                        Identifier {
                            id: Name("collections"),
                            range: 5..16,
                        },
                    ),
                    names: [
                        Alias {
                            range: 24..27,
                            name: Identifier {
                                id: Name("abc"),
                                range: 24..27,
                            },
                            asname: None,
                        },
                    ],
                    level: 0,
                },
            ),
            TypeAlias(
                StmtTypeAlias {
                    range: 28..53,
                    name: Name(
                        ExprName {
                            range: 33..34,
                            id: Name("x"),
                            ctx: Store,
                        },
                    ),
                    type_params: None,
                    value: Subscript(
                        ExprSubscript {
                            range: 37..53,
                            value: Attribute(
                                ExprAttribute {
                                    range: 37..49,
                                    value: Name(
                                        ExprName {
                                            range: 37..40,
                                            id: Name("abc"),
                                            ctx: Load,
                                        },
                                    ),
                                    attr: Identifier {
                                        id: Name("Callable"),
                                        range: 41..49,
                                    },
                                    ctx: Load,
                                },
                            ),
                            slice: List(
                                ExprList {
                                    range: 50..52,
                                    elts: [],
                                    ctx: Load,
                                },
                            ),
                            ctx: Load,
                        },
                    ),
                },
            ),
        ],
    },
)

instead of an error of invalid syntax, then the compiler give us a Rust error that should never happen

this is the error visualized in Cpython


type x = abc.Callable[[]]
  File "<stdin>", line 1
    type x = abc.Callable[[]]
         ^
SyntaxError: invalid syntax

@arihant2math
Copy link
Collaborator Author

It shouldn't error out at all, as cpython does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiler Area: compiler C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants