type aliases no longer work?

Open
#116 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
compilers

Research direction

Start by reproducing the error on cinder/3.10 with fannkuch_static_lib.py and nqueens_static_lib.py, then inspect the ArrayI64 alias and the count annotations shown in the issue. Compare the alias form with the direct Array[int64] form and trace where the compiler reports the TypedSyntaxError. Done means the alias form behaves consistently with the direct type form without the reported mismatch.

Written by the indexing model from the issue text.

Description

On cinder/3.10, fannkuch_static_lib.py and nqueens_static_lib.py give errors like this:

  File "fannkuch_static_lib.py", line 29
    count[r - 1] = r
compiler.errors.TypedSyntaxError: type mismatch: int64 cannot be assigned to dynamic

The array count is defined using a type alias:

ArrayI64 = Array[int64]
....
count: ArrayI64 = ArrayI64(range(1, nb + 1))

Changing the definition to use the type directly removes the error:

count: Array[int64] = ArrayI64(range(1, nb + 1))

That's surprising! Did something break with type aliases?

cc @vivaan2006 who helped discover this

Dominant language
Python
Stars
3.8k
Forks
139
PR merge metrics
No merged PRs in 30d

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.

More from facebookincubator/MetaPython

All issues in facebookincubator/MetaPython

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.