Skip to content

Generic constraints can be bypassed using proc default initialization #1428

Open
@alaviss

Description

@alaviss

Example

type
  O[T: Ordinal] = object
    x: T

proc invalid[T]: O[T] = discard

let x = invalid[string]()
echo typeof(x)

Actual Output

O[system.string]

Expected Output

This should not compile

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompiler/semRelated to semantic-analysis system of the compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions