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

VM replaces declared type with alias #19198

Closed
jcosborn opened this issue Nov 29, 2021 · 0 comments
Closed

VM replaces declared type with alias #19198

jcosborn opened this issue Nov 29, 2021 · 0 comments

Comments

@jcosborn
Copy link
Contributor

In the below code, the type of x is set to Foo even though it was declared int and Foo is not in scope.
This causes a compiler crash later when x is used since Foo is a generic and wasn't instantiated.

Example

block:
  type
    Foo[n: static int] = int

block:
  static:
    let x = int 1
    echo x.type   # Foo                                                                   

block:
  static:
    let x = int 1
    let y = x + 1
    # Error: unhandled exception: value out of range: -8 notin 0 .. 65535 [RangeDefect]   
    echo y

Current Output

Foo
fatal.nim(53)            sysFatal
Error: unhandled exception: value out of range: -8 notin 0 .. 65535 [RangeDefect]

Expected Output

int
2

Possible Solution

Additional Information

This happens on devel, 1.6 and 1.4.

This is related to #15356.

Araq added a commit that referenced this issue Dec 2, 2021
@Araq Araq closed this as completed in f90620f Dec 4, 2021
narimiran pushed a commit that referenced this issue Dec 6, 2021
* fixes #19198 [backport:1.6]

* added a test case

(cherry picked from commit f90620f)
PMunch pushed a commit to PMunch/Nim that referenced this issue Mar 28, 2022
* fixes nim-lang#19198 [backport:1.6]

* added a test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants