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

Default object values silently override generic types #23594

Open
carrexxii opened this issue May 10, 2024 · 0 comments
Open

Default object values silently override generic types #23594

carrexxii opened this issue May 10, 2024 · 0 comments
Assignees

Comments

@carrexxii
Copy link

Description

Using a default value can silently override a generic type:

type
  Gen[T] = object
    a: T = 1.0

  Spec32 = Gen[float32]
  Spec64 = Gen[float64]

var
  a: Spec32
  b: Spec64
echo(sizeof a, " vs ", sizeof b)

Nim Version

Nim Compiler Version 2.0.4 [Linux: amd64]

Current Output

8 vs 8

Expected Output

4 vs 8

Possible Solution

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants