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

const variables lose their type information #5

Closed
Vindaar opened this issue Jun 2, 2021 · 1 comment
Closed

const variables lose their type information #5

Vindaar opened this issue Jun 2, 2021 · 1 comment

Comments

@Vindaar
Copy link
Member

Vindaar commented Jun 2, 2021

I've stumbled on this before, but ignored it, because I didn't have the time to isolate it and provide a Nim issue about it. But now I got caught by this bug again, so it's time to at least file an issue here.

If one defines a variable as const that has an associated type, the type information will be lost by the time this variable is used in some computation. If the type contains SI prefixes this is especially dangerous, because one misses conversion factors. Raw type information is a (comparatively) minor issue, because it would at least show up as a CT error due to missing types (which still might happen of course, but in cases where the types match regardless (i.e. just a computation and manual conversion to float) the numbers are plain wrong.

const g_aγ = 1e-10.GeV⁻¹
let x = g_aγ * 1.0.eV²

will result in x of type eV² and the conversion factor of 1e-9 missing from the result.

@Vindaar
Copy link
Member Author

Vindaar commented Jul 27, 2022

Closed by #25.

@Vindaar Vindaar closed this as completed Jul 27, 2022
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

1 participant