Skip to content

Do not simplify away field as clause - it breaks compilation#43124

Merged
CyrusNajmabadi merged 2 commits intodotnet:masterfrom
GrahamTheCoder:simplification/field-as-clause
Apr 16, 2020
Merged

Do not simplify away field as clause - it breaks compilation#43124
CyrusNajmabadi merged 2 commits intodotnet:masterfrom
GrahamTheCoder:simplification/field-as-clause

Conversation

@GrahamTheCoder
Copy link
Copy Markdown
Contributor

Fixes #43123

If there's a case when the As clause actually should be removed (e.g. if you want to do so when option strict is off), let me know and I'll update.

I fixed the obvious explicit test of this. I expect there will be some other tests that need fixing up. My system struggles to run the tests locally so I'll deal with them as they appear from CI.

If option strict is on: Removing the as clause causes a compile error
If option strict is off: It changes the inferred type of the field to be Object in all cases
@GrahamTheCoder GrahamTheCoder requested a review from a team as a code owner April 6, 2020 20:25
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

CyrusNajmabadi commented Apr 6, 2020

@jcouv @KathleenDollard do you know if there are any cases in VB where a dim field = ... will not infer object as the type of dim, but will instead use whatever is in ... to determine the field type?

@GrahamTheCoder
Copy link
Copy Markdown
Contributor Author

From https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/dim-statement

Type inference applies at the procedure level. It does not apply outside a procedure in a class, structure, module, or interface.

@jcouv
Copy link
Copy Markdown
Member

jcouv commented Apr 6, 2020

@CyrusNajmabadi I don't know. I didn't expect object to be inferred in Dim field = 5 either ;-)

@jinujoseph jinujoseph added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Apr 7, 2020
@GrahamTheCoder
Copy link
Copy Markdown
Contributor Author

Looks like the tests didn't start properly, then timed out, I assume this just needs a rerun since I can't see any actual failing test.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@GrahamTheCoder Tests are running now

@GrahamTheCoder
Copy link
Copy Markdown
Contributor Author

All green - let me know if you need anything else

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Thanks!

@CyrusNajmabadi CyrusNajmabadi merged commit e542a0b into dotnet:master Apr 16, 2020
@ghost ghost added this to the Next milestone Apr 16, 2020
@sharwell sharwell modified the milestones: Next, temp, 16.7.P1 Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not simplify away field as clause - it breaks compilation

5 participants