You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by joprice June 15, 2024
When a type has the Erase attribute, you can still attempt to call the constructor. The code will generate a call to the name-mangled ctor wrapper, which doesn't exist, and fail at runtime. I would expect this to fail at compile time with an error such as "no constructor exists for erased type X". Of course, this might be easier said than done, and not sure if there's some reason it works this way.
This also might seem like a bit of a contrived case, but I've hit this multiple times in the few weeks I've been using fable, where I modify existing code, starting with some static functions and Erased to avoid the reflection and constructor generation, then switching to have some state and forgetting to remove it.
openFable.Core[<Erase>]typeX(a: string)=member_.getA()= a
letcreate()= X("a")
Discussed in #3850
Originally posted by joprice June 15, 2024
When a type has the
Erase
attribute, you can still attempt to call the constructor. The code will generate a call to the name-mangled ctor wrapper, which doesn't exist, and fail at runtime. I would expect this to fail at compile time with an error such as "no constructor exists for erased type X". Of course, this might be easier said than done, and not sure if there's some reason it works this way.This also might seem like a bit of a contrived case, but I've hit this multiple times in the few weeks I've been using fable, where I modify existing code, starting with some static functions and Erased to avoid the reflection and constructor generation, then switching to have some state and forgetting to remove it.
https://fable.io/repl/#?code=PYBwpgdgBAYghgIwDZgHQGFgCcwFgBQBA2gDwCiWcAzmAHwC6BALgJ7hQAaAFHAFxRUmWAJYQA5gEooAXigEoUALZhFCMFigB9VGLBMAglymy4BAiiZQAxjjhMwRmZy4AiOC4lA&html=Q&css=Q
The text was updated successfully, but these errors were encountered: