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

Generic function with cast to templated type fails at C++ stage #1070

Open
mnlrsn opened this issue Aug 12, 2022 · 0 comments
Open

Generic function with cast to templated type fails at C++ stage #1070

mnlrsn opened this issue Aug 12, 2022 · 0 comments

Comments

@mnlrsn
Copy link
Contributor

mnlrsn commented Aug 12, 2022

To reproduce:

function f<T>(anon n: u64) -> T {
    let v: T = n as! T

    return v
}

function main() {
    let value: f64 =  f<f64>(1u64)
    println("{}", value)
}

Error message:

runtime/Jakt/TypeCasts.h:23:12: error: 'double' is not a class type
    return dynamic_cast<CopyConst<InputType, OutputType>*>(&input);
           ^           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
runtime/Jakt/TypeCasts.h:50:12: note: in instantiation of function template specialization 'Jakt::is<double, const unsigned long>' requested here
    VERIFY(is<OutputType>(input));
           ^
runtime/Jakt/Assertions.h:13:20: note: expanded from macro 'VERIFY'
#    define VERIFY assert
                   ^
build/Test-Generic-Return-Float.cpp:9:14: note: in instantiation of function template specialization 'Jakt::verify_cast<double, const unsigned long>' requested here
const T v = (verify_cast<T>((n)));
             ^
build/Test-Generic-Return-Float.cpp:16:19: note: in instantiation of function template specialization 'Jakt::f<double>' requested here
const f64 value = f<f64>(static_cast<u64>(1ULL));
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