-
Notifications
You must be signed in to change notification settings - Fork 66
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
Custom implicit Ctype is not used in dynamic mode #613
Comments
VB is stuck in limbo here:
In the grand scheme of things, this issue is a very minor annoyance. In practice, we VB'ers should stick with |
there's a certain irony that for many years, the curly-bracket people derided VB because 'Variant' existed. Then when they realise that a dynamic type is useful, VB gets derided for not having the 'new' flavour of 'Variant', now known as 'dynamic'. |
@pricerc @rskar-git But it should be lowerd to: Dim s As String
Try
s = CType(o, String)
Catch ex As InvalidCastException
Try
s = CTypeDynamic(o, GetType(String))
Catch
Throw
End Try
Catch
Throw
End Try And it will work perfectly. @CyrusNajmabadi @KathleenDollard |
@VBAndCs if you think there is an issue in Roslyn, please file an issue there.
If you think the compiler is not behaving as per the spec, please make sure to link to the parts of the spec related to this and explain how the compiled code is not in line with it. Thanks! |
VB can't call the implicit ctype operator on dynamic objects. This code gives the runtime error: Can't convert from Test To String:
While the same code runs correctly in C#:
I think Vb should adapt the C# spcs about this, after all vb was a dynamic langish since before .NET, where even declaring variables was not mandatort (Option Explicit Off was the default in old vb versions before dotnet.)
Also, I suggest that dynamically or not, vb should use .ToString to implicitly convert any type to a string as lomg as ther is no a suitable CType defined to do that. This is more like how VB does things.
The text was updated successfully, but these errors were encountered: