Skip to content

"type expected" error for proc resolution with static[int]] #10833

@Nycto

Description

@Nycto

I expect the example below to compile, but it instead fails with a cryptic error message

Example

type Foo*[A; B; C: static[int]] = object

proc build*[A; B; C: static[int]](field: string): Foo[A, B, C] =
    discard

proc build*[A; B; C: static[int]](): Foo[A, B, C] =
    build[A, B, C]("foo")

type
    Bar = object
    Baz = object

discard build[Bar, Baz, 1]()

Current Output

foo.nim(13, 14) template/generic instantiation from here
foo.nim(7, 17) Error: type expected

Expected Output

I expect this code to compile

Possible Solution

I have no proposed solution, but I've found that renaming one of the methods works around the bug:

type Foo*[A; B; C: static[int]] = object

proc build*[A; B; C: static[int]](field: string): Foo[A, B, C] =
    discard

proc buildThing*[A; B; C: static[int]](): Foo[A, B, C] =
    build[A, B, C]("foo")

type
    Bar = object
    Baz = object

discard buildThing[Bar, Baz, 1]()

Additional Information

> nim -v
Nim Compiler Version 0.19.4 [Linux: amd64]
Compiled at 2019-02-01
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: b6d96cafc8bcad1f3d32f2910b25cd11a93f7751
active boot switches: -d:release

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions