Skip to content

Defaults don't work for first generic parameter #25004

Open
@arnetheduck

Description

@arnetheduck

Nim Version

2.2

Description

Generic parameters can be given defaults, but actually using the default is evasive.

type Aaa[F: static int = 0] = object

echo default(Aaa[0]) # works
# echo default(Aaa[]) # error
# echo default(Aaa) # error

type Bbb[T = void] = object
echo default(Bbb[void])
# echo default(Bbb[]) # error
# echo default(Bbb) # error

# Skipping the second parameter works
type Ccc[T, X = void] = object
echo default(Ccc[void])

Not sure which syntax is most reasonable, but probably the one with [].

Current Output


Expected Output


Known Workarounds

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions