Skip to content
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

Checker: check unfinished obj expression inside computations #16413

Merged
merged 2 commits into from
Dec 11, 2023

Conversation

auduchinok
Copy link
Member

Allows type checking of unfinished object expressions, like these:

{ new T() }
{ new T(arg1, arg2) }

Before with is typed, this is parsed as a computation expression and these errors are reported:

Expression/Object - Class 16.fs (7,1)-(7,12) typecheck error
  Invalid object expression.
  Objects without overrides or interfaces should use the expression form 'new Type(args)' without braces.

Expression/Object - Class 16.fs (7,1)-(7,12) typecheck error
  Invalid record, sequence or computation expression.
  Sequence expressions should be of the form 'seq { ... }'

The problematic part is neither the type usage, nor the arguments are checked. This PR adds checking of such expressions.

I'm going to look into adding tests later, for now I'd like to see what does CI say about the change.

@auduchinok auduchinok requested a review from a team as a code owner December 8, 2023 17:07
@auduchinok auduchinok changed the title Checker: check unfinished obj expression type inside parsed computati… Checker: check unfinished obj expression inside computations Dec 8, 2023
Copy link
Member

@psfinaki psfinaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@psfinaki psfinaki enabled auto-merge (squash) December 11, 2023 11:41
@psfinaki psfinaki merged commit 297166e into dotnet:main Dec 11, 2023
26 checks passed
@auduchinok auduchinok deleted the checker-seqExpr-objExpr branch December 12, 2023 11:35
OwnageIsMagic added a commit to OwnageIsMagic/fsharp that referenced this pull request Dec 21, 2023
* upstream/main: (166 commits)
  typo in foldBack summary (dotnet#16453)
  Fix for dotnet#83 (improve constraint error message) (dotnet#16304)
  Name resolution: resolve interfaces in expressions (dotnet#15660)
  AddExplicitReturnType refactoring (dotnet#16077)
  Disabling 2 tests: running for too long, causing CI timeouts
  Improve value restriction error message dotnet#1103 (dotnet#15877)
  Parens: Keep parens for non-identical infix operator pairs with same precedence (dotnet#16372)
  More release note entries (dotnet#16438)
  Using Ordinal is both faster and more correct as our intent is to do … (dotnet#16439)
  merge (dotnet#16427)
  Optimize empty string compares (dotnet#16435)
  Checker: recover on unresolved type in 'inherit' member (dotnet#16429)
  Release notes proposal (dotnet#16377)
  [main] Update dependencies from dotnet/source-build-reference-packages (dotnet#16411)
  Allow usage of [<TailCall>] with older FSharp.Core package versions (dotnet#16373)
  Parser: recover on unfinished 'as' patterns (dotnet#16404)
  Parens: Keep parens in method calls in dot-lambdas (dotnet#16395)
  Checker: check unfinished obj expression inside computations (dotnet#16413)
  Added default dotnet-tools + additional tasks to launch them (dotnet#16409)
  make `remarks` and `returns` visible in quick info (dotnet#16417)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants