Nimblesite / Nimblesite/Basilisk

Generics

Open
#419 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
54
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Basilisk doesn't seem to handle rather basic examples involving generics, for example:

from typing import assert_type

class P: ...

def duplicate[T](value: T) -> tuple[T, T]:
    return value, value

assert_type(duplicate(P()), tuple[P, P])

Basilisk fails this assertion and incorrectly infers tuple[T, T] (leaking type variables) instead of tuple[P, P].

Using list[T] or int | T in the return type leads to similar failures.

It also seems to rely on the fact that type variables are capitalized? It fails this assertion and infers t instead of int:

def identity[t](value: t) -> t:
    return value

assert_type(identity(1), int)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the generic-function and assert_type examples from the issue, then trace Basilisk's generic inference and type-variable handling. Done means the examples infer tuple[P, P] and int rather than leaking or preserving the type variables.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.