VB.NET CDate(CStr(Nothing)) should not emit Conversions::ToDate(string) call #2780
Labels
Area-Compilers
Bug
Resolution-By Design
The behavior reported in the issue matches the current design
Tenet-Compatibility
Violation of forwards/backwards compatibility in a design-time piece.
Verification Not Required
Milestone
The below succeeds when compiled with Visual Studio 2013, but fails at runtime when compiled with Visual Studio 2015 RC:
Edited stack trace:
Expected behaviour: conversion is expected to succeed with
d = Date.MinValue
Reason: old compiler used to omit call to
Conversions.ToDate
where it could determine that the argument is always a null string.IL generated by Roslyn (Visual Studio 2015 RC):
IL generated by Visual Studio 2013 VB.NET compiler (note: call to
Conversions.ToDate
omitted):Implications
The new behaviour seems logical, but it breaks existing code in a way which is difficult to detect and fix. There is no way for a developer to easily find all occurrences of the above in a project/solution. The situation is worse with
Option Strict Off
and when theCDate
call is implied (below generates similar IL and succeeds in VS 2013, but errors in 2015):In the absence of a compiler warning the occurrences of the above are hard to find and fix in a large codebase.
The text was updated successfully, but these errors were encountered: