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
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")
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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
Beta Was this translation helpful? Give feedback.
All reactions