diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md
index a7d549b23bd..15b5f1248e6 100644
--- a/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md
+++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.200.md
@@ -8,7 +8,7 @@
* Fix nullness inference for member val and other OO scenarios ([PR #17845](https://github.com/dotnet/fsharp/pull/17845))
### Added
-
+* Deprecate places where `seq` can be omitted. ([Language suggestion #1033](https://github.com/fsharp/fslang-suggestions/issues/1033), [PR #17772](https://github.com/dotnet/fsharp/pull/17772))
* Support literal attribute on decimals ([PR #17769](https://github.com/dotnet/fsharp/pull/17769))
### Changed
diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md
index b18d08e30c3..a38e14215dc 100644
--- a/docs/release-notes/.Language/preview.md
+++ b/docs/release-notes/.Language/preview.md
@@ -1,6 +1,7 @@
### Added
* Better generic unmanaged structs handling. ([Language suggestion #692](https://github.com/fsharp/fslang-suggestions/issues/692), [PR #12154](https://github.com/dotnet/fsharp/pull/12154))
+* Deprecate places where `seq` can be omitted. ([Language suggestion #1033](https://github.com/fsharp/fslang-suggestions/issues/1033), [PR #17772](https://github.com/dotnet/fsharp/pull/17772))
### Fixed
diff --git a/docs/release-notes/.VisualStudio/17.13.md b/docs/release-notes/.VisualStudio/17.13.md
new file mode 100644
index 00000000000..dae07600e1b
--- /dev/null
+++ b/docs/release-notes/.VisualStudio/17.13.md
@@ -0,0 +1,8 @@
+### Fixed
+
+### Added
+* Code fix for adding missing `seq`. ([PR #17772](https://github.com/dotnet/fsharp/pull/17772))
+
+### Changed
+
+### Breaking Changes
diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs
index 30375d047f4..9c14787d113 100644
--- a/src/Compiler/Checking/Expressions/CheckExpressions.fs
+++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs
@@ -5891,6 +5891,17 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE
TcForEachExpr cenv overallTy env tpenv (seqExprOnly, isFromSource, pat, synEnumExpr, synBodyExpr, m, spFor, spIn, m)
| SynExpr.ComputationExpr (hasSeqBuilder, comp, m) ->
+ let isIndexRange = match comp with | SynExpr.IndexRange _ -> true | _ -> false
+ let deprecatedPlacesWhereSeqCanBeOmitted =
+ cenv.g.langVersion.SupportsFeature LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted
+ if
+ deprecatedPlacesWhereSeqCanBeOmitted
+ && isIndexRange
+ && not hasSeqBuilder
+ && not cenv.g.compilingFSharpCore
+ then
+ warning (Error(FSComp.SR.chkDeprecatePlacesWhereSeqCanBeOmitted (), m))
+
let env = ExitFamilyRegion env
cenv.TcSequenceExpressionEntry cenv env overallTy tpenv (hasSeqBuilder, comp) m
diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt
index b5a50afc7c0..9a6b69fa2ff 100644
--- a/src/Compiler/FSComp.txt
+++ b/src/Compiler/FSComp.txt
@@ -1783,4 +1783,6 @@ featureEmptyBodiedComputationExpressions,"Support for computation expressions wi
featureAllowAccessModifiersToAutoPropertiesGettersAndSetters,"Allow access modifiers to auto properties getters and setters"
3871,tcAccessModifiersNotAllowedInSRTPConstraint,"Access modifiers cannot be applied to an SRTP constraint."
featureAllowObjectExpressionWithoutOverrides,"Allow object expressions without overrides"
-3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern."
\ No newline at end of file
+3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern."
+3873,chkDeprecatePlacesWhereSeqCanBeOmitted,"This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'"
+featureDeprecatePlacesWhereSeqCanBeOmitted,"Deprecate places where 'seq' can be omitted"
\ No newline at end of file
diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs
index 5c311237594..3488a3399e1 100644
--- a/src/Compiler/Facilities/LanguageFeatures.fs
+++ b/src/Compiler/Facilities/LanguageFeatures.fs
@@ -94,6 +94,7 @@ type LanguageFeature =
| ParsedHashDirectiveArgumentNonQuotes
| EmptyBodiedComputationExpressions
| AllowObjectExpressionWithoutOverrides
+ | DeprecatePlacesWhereSeqCanBeOmitted
/// LanguageVersion management
type LanguageVersion(versionText) =
@@ -219,6 +220,7 @@ type LanguageVersion(versionText) =
LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work
LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters, previewVersion
LanguageFeature.AllowObjectExpressionWithoutOverrides, previewVersion
+ LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted, previewVersion
]
static let defaultLanguageVersion = LanguageVersion("default")
@@ -375,6 +377,7 @@ type LanguageVersion(versionText) =
| LanguageFeature.ParsedHashDirectiveArgumentNonQuotes -> FSComp.SR.featureParsedHashDirectiveArgumentNonString ()
| LanguageFeature.EmptyBodiedComputationExpressions -> FSComp.SR.featureEmptyBodiedComputationExpressions ()
| LanguageFeature.AllowObjectExpressionWithoutOverrides -> FSComp.SR.featureAllowObjectExpressionWithoutOverrides ()
+ | LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted -> FSComp.SR.featureDeprecatePlacesWhereSeqCanBeOmitted ()
/// Get a version string associated with the given feature.
static member GetFeatureVersionString feature =
diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi
index 7408300b943..6396f7b72c0 100644
--- a/src/Compiler/Facilities/LanguageFeatures.fsi
+++ b/src/Compiler/Facilities/LanguageFeatures.fsi
@@ -85,6 +85,7 @@ type LanguageFeature =
| ParsedHashDirectiveArgumentNonQuotes
| EmptyBodiedComputationExpressions
| AllowObjectExpressionWithoutOverrides
+ | DeprecatePlacesWhereSeqCanBeOmitted
/// LanguageVersion management
type LanguageVersion =
diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf
index 958a1357ac9..4a6bbf58d2f 100644
--- a/src/Compiler/xlf/FSComp.txt.cs.xlf
+++ b/src/Compiler/xlf/FSComp.txt.cs.xlf
@@ -52,6 +52,11 @@
Tento výraz je anonymní záznam, použijte {{|...|}} místo {{...}}.
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
Duplicitní parametr Parametr {0} byl v této metodě použit vícekrát.
@@ -322,6 +327,11 @@
opravit překlad názvů typů delegátů, viz https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
vzor discard ve vazbě použití
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- Neplatný výraz záznamu, pořadí nebo výpočtu. Výrazy pořadí by měly mít notaci seq {{ ... }}.
+ Neplatný výraz záznamu, pořadí nebo výpočtu. Výrazy pořadí by měly mít notaci seq {{ ... }}.
diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf
index d7233a5d2fc..1546541aee7 100644
--- a/src/Compiler/xlf/FSComp.txt.de.xlf
+++ b/src/Compiler/xlf/FSComp.txt.de.xlf
@@ -52,6 +52,11 @@
Dieser Ausdruck ist ein anonymer Datensatz. Verwenden Sie {{|...|}} anstelle von {{...}}.
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
Doppelter Parameter. Der Parameter „{0}“ wurde in dieser Methode mehrmals verwendet.
@@ -322,6 +327,11 @@
Informationen zur Problembehebung bezüglich der Auflösung von Delegattypnamen finden Sie unter https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
Das Verwerfen des verwendeten Musters ist verbindlich.
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- Ungültiger Datensatz-, Sequenz- oder Berechnungsausdruck. Sequenzausdrücke müssen das Format "seq {{ ... }}" besitzen.
+ Ungültiger Datensatz-, Sequenz- oder Berechnungsausdruck. Sequenzausdrücke müssen das Format "seq {{ ... }}" besitzen.
diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf
index 1b3205ffa53..db357235565 100644
--- a/src/Compiler/xlf/FSComp.txt.es.xlf
+++ b/src/Compiler/xlf/FSComp.txt.es.xlf
@@ -52,6 +52,11 @@
Esta expresión es un registro anónimo; use {{|...|}} en lugar de {{...}}.
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
Parámetro duplicado. El parámetro '{0}' se ha usado más una vez en este método.
@@ -322,6 +327,11 @@
corrección para la resolución de nombres de tipo de delegado, consulte https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
descartar enlace de patrón en uso
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- Expresión de registro, secuencia o cómputo no válida. Las expresiones de secuencia deben tener el formato 'seq {{ ... }}'.
+ Expresión de registro, secuencia o cómputo no válida. Las expresiones de secuencia deben tener el formato 'seq {{ ... }}'.
diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf
index 018180a8fb6..dca6fe2b78d 100644
--- a/src/Compiler/xlf/FSComp.txt.fr.xlf
+++ b/src/Compiler/xlf/FSComp.txt.fr.xlf
@@ -52,6 +52,11 @@
Cette expression est un enregistrement anonyme, utilisez {{|...|}} au lieu de {{...}}.
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
Paramètre dupliqué. Le paramètre « {0} » a été utilisé une fois de plus dans cette méthode.
@@ -322,6 +327,11 @@
corriger pour résoudre les noms de types délégués, voir https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
annuler le modèle dans la liaison d’utilisation
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- Expression d'enregistrement, de séquence ou de calcul non valide. Les expressions de séquence doivent avoir le format 'seq {{ ... }}'
+ Expression d'enregistrement, de séquence ou de calcul non valide. Les expressions de séquence doivent avoir le format 'seq {{ ... }}'
diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf
index 7cc3f46259b..0d2815aa9b2 100644
--- a/src/Compiler/xlf/FSComp.txt.it.xlf
+++ b/src/Compiler/xlf/FSComp.txt.it.xlf
@@ -52,6 +52,11 @@
Questa espressione è un record anonimo. Usa {{|...|}} invece di {{...}}.
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
Parametro duplicato. Il parametro '{0}' è stato utilizzato più volte in questo metodo.
@@ -322,6 +327,11 @@
correggere la risoluzione dei nomi dei tipi delegati, vedere https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
rimuovi criterio nell'utilizzo dell'associazione
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- Espressione di calcolo, sequenza o record non valida. Il formato delle espressioni sequenza deve essere 'seq {{ ... }}'
+ Espressione di calcolo, sequenza o record non valida. Il formato delle espressioni sequenza deve essere 'seq {{ ... }}'
diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf
index 10c5f06f4ff..d660cf6768b 100644
--- a/src/Compiler/xlf/FSComp.txt.ja.xlf
+++ b/src/Compiler/xlf/FSComp.txt.ja.xlf
@@ -52,6 +52,11 @@
この式は匿名レコードであり、{{...}} の代わりに {{|...|}} を使用してください。
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
パラメーターが重複しています。パラメーター '{0}' は、このメソッドで 1 回以上使用されています。
@@ -322,6 +327,11 @@
デリゲート型名の解決を修正するには、https://github.com/dotnet/fsharp/issues/10228 を参照してください
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
使用バインドでパターンを破棄する
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- 無効なレコード、シーケンス式、またはコンピュテーション式です。シーケンス式は 'seq {{ ... }}' という形式にしてください。
+ 無効なレコード、シーケンス式、またはコンピュテーション式です。シーケンス式は 'seq {{ ... }}' という形式にしてください。
diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf
index 94cd344f052..a0f3d1411b4 100644
--- a/src/Compiler/xlf/FSComp.txt.ko.xlf
+++ b/src/Compiler/xlf/FSComp.txt.ko.xlf
@@ -52,6 +52,11 @@
이 식은 익명 레코드입니다. {{...}} 대신 {{|...|}}을 사용하세요.
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
매개 변수가 중복되었습니다. 이 메소드에서 매개 변수 '{0}'이(가) 두 번 이상 사용되었습니다.
@@ -322,6 +327,11 @@
대리자 형식 이름의 해결 방법을 수정합니다. https://github.com/dotnet/fsharp/issues/10228 참조하세요.
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
사용 중인 패턴 바인딩 무시
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- 레코드, 시퀀스 또는 계산 식이 잘못되었습니다. 시퀀스 식의 형식은 'seq {{ ... }}'여야 합니다.
+ 레코드, 시퀀스 또는 계산 식이 잘못되었습니다. 시퀀스 식의 형식은 'seq {{ ... }}'여야 합니다.
diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf
index 01f2ff1d5e3..fcb2638d5a2 100644
--- a/src/Compiler/xlf/FSComp.txt.pl.xlf
+++ b/src/Compiler/xlf/FSComp.txt.pl.xlf
@@ -52,6 +52,11 @@
To wyrażenie jest rekordem anonimowym. Użyj {{|...|}} zamiast {{...}}.
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
Zduplikowany parametr. Parametr „{0}” został użyty więcej niż raz w tej metodzie.
@@ -322,6 +327,11 @@
naprawa rozpoznawania nazw typów delegatów, sprawdź stronę https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
odrzuć wzorzec w powiązaniu użycia
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- Nieprawidłowe wyrażenie rekordu, sekwencji lub obliczenia. Wyrażenia sekwencji powinny mieć postać „seq {{ ... }}”
+ Nieprawidłowe wyrażenie rekordu, sekwencji lub obliczenia. Wyrażenia sekwencji powinny mieć postać „seq {{ ... }}”
diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf
index 63da6a667b1..a27487e1c20 100644
--- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf
+++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf
@@ -52,6 +52,11 @@
Esta expressão é um registro anônimo, use {{|...|}} em vez de {{...}}.
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
Parâmetro duplicado. O parâmetro '{0}' foi usado mais de uma vez neste método.
@@ -322,6 +327,11 @@
corrigir para resolução de nomes de tipos delegados, consulte https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
descartar o padrão em uso de associação
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- Expressão de registro, sequência ou computação inválida. Expressões de sequência devem estar na forma 'seq {{ ... }}'
+ Expressão de registro, sequência ou computação inválida. Expressões de sequência devem estar na forma 'seq {{ ... }}'
diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf
index 231bc83103b..18c6c501759 100644
--- a/src/Compiler/xlf/FSComp.txt.ru.xlf
+++ b/src/Compiler/xlf/FSComp.txt.ru.xlf
@@ -52,6 +52,11 @@
Это выражение является анонимной записью. Используйте {{|...|}} вместо {{...}}.
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
Повторяющийся параметр. Параметр "{0}" использовался в этом методе несколько раз.
@@ -322,6 +327,11 @@
исправить разрешение имен типов делегатов, см. https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
шаблон отмены в привязке использования
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- Недопустимая запись, выражение последовательности или вычислительное выражение. Выражения последовательностей должны иметь форму "seq {{ ... }}'
+ Недопустимая запись, выражение последовательности или вычислительное выражение. Выражения последовательностей должны иметь форму "seq {{ ... }}'
diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf
index a3bab7e5a92..94a7a284470 100644
--- a/src/Compiler/xlf/FSComp.txt.tr.xlf
+++ b/src/Compiler/xlf/FSComp.txt.tr.xlf
@@ -52,6 +52,11 @@
Bu ifade, anonim bir kayıt, {{...}} yerine {{|...|}} kullanın.
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
Yinelenen parametre. '{0}' parametresi bu metotta bir kereden fazla kullanıldı.
@@ -322,6 +327,11 @@
temsilci türü adlarının çözümlenmesiyle ilgili sorunun çözümü için bkz. https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
kullanım bağlamasında deseni at
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- Geçersiz kayıt, dizi veya hesaplama ifadesi. Dizi ifadeleri 'seq {{ ... }}' biçiminde olmalıdır
+ Geçersiz kayıt, dizi veya hesaplama ifadesi. Dizi ifadeleri 'seq {{ ... }}' biçiminde olmalıdır
diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
index 579ac9b79c3..ba5826eb686 100644
--- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
+++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
@@ -52,6 +52,11 @@
此表达式是匿名记录,请使用 {{|...|}} 而不是 {{...}}。
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
参数重复。此方法中多次使用了参数“{0}”。
@@ -322,6 +327,11 @@
修复了委托类型名称的解析,请参阅 https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
放弃使用绑定模式
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- 记录、序列或计算表达式无效。序列表达式的格式应为“seq {{ ... }}”
+ 记录、序列或计算表达式无效。序列表达式的格式应为“seq {{ ... }}”
diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
index 09818a7487b..b039caf9e93 100644
--- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
+++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
@@ -52,6 +52,11 @@
此運算式是匿名記錄,請使用 {{|...|}} 而不是 {{...}}。
+
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+ This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'
+
+
Duplicate parameter. The parameter '{0}' has been used more that once in this method.
重複的參數。參數 '{0}' 在此方法中使用多次。
@@ -322,6 +327,11 @@
修正委派類型名稱的解析,請參閱 https://github.com/dotnet/fsharp/issues/10228
+
+ Deprecate places where 'seq' can be omitted
+ Deprecate places where 'seq' can be omitted
+
+
discard pattern in use binding
捨棄使用繫結中的模式
@@ -4524,7 +4534,7 @@
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq {{ ... }}'
- 無效的記錄、循序項或計算運算式。循序項運算式應該是 'seq {{ ... }}' 形式。
+ 無效的記錄、循序項或計算運算式。循序項運算式應該是 'seq {{ ... }}' 形式。
diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
index 029ec14b0b4..af431847400 100644
--- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
+++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj
@@ -223,6 +223,7 @@
+
@@ -237,7 +238,6 @@
-
diff --git a/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressions/E_SequenceExpressions01.fs b/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressions/E_SequenceExpressions01.fs
new file mode 100644
index 00000000000..37ca58c3db6
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressions/E_SequenceExpressions01.fs
@@ -0,0 +1,76 @@
+{ 1..10 }
+
+{ 1..5..10 }
+
+[| { 1..10 } |]
+
+[| { 1..5..10 } |]
+
+let a = { 1..10 }
+
+let a3 = { 1..10..20 }
+
+let b = [| { 1..10 } |]
+
+let b3 = [| { 1..10..20 } |]
+
+let c = [ { 1..10 } ]
+
+[| { 1..10 } |]
+
+[| yield { 1..10 } |]
+
+[ { 1..10 } ]
+
+[ { 1..10..10 } ]
+
+[ yield { 1..10 } ]
+
+[ yield { 1..10..20 } ]
+
+ResizeArray({ 1..10 })
+
+ResizeArray({ 1..10..20 })
+
+let fw start finish = [ for x in { start..finish } -> x ]
+
+let fe start finish = [| for x in { start..finish } -> x |]
+
+for x in { 1..10 } do ()
+
+for x in { 1..5..10 } do ()
+
+let f = Seq.head
+
+let a2 = f { 1..6 }
+
+let a23 = f { 1..6..10 }
+
+let b2 = set { 1..6 }
+
+let f10 start finish = for x in { start..finish } do ignore (float x ** float x)
+
+let (..) _ _ = "lol"
+
+let lol1 = { 1..10 }
+
+{ 1..5..10 }
+
+let resultInt = Seq.length {1..8}
+
+let resultInt2 funcInt = Seq.map3 funcInt { 1..8 } { 2..9 } { 3..10 }
+
+let verify c = failwith "not implemented"
+
+Seq.splitInto 4 {1..5} |> verify { 1.. 10 }
+
+seq [ {1..4}; {5..7}; {8..10} ]
+
+Seq.allPairs { 1..7 } Seq.empty
+
+Seq.allPairs Seq.empty { 1..7 }
+
+let intArr1 = [| yield! {1..100}
+ yield! {1..100} |]
+
+Array.ofSeq {1..10}
\ No newline at end of file
diff --git a/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressionTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressions/SequenceExpressionTests.fs
similarity index 59%
rename from tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressionTests.fs
rename to tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressions/SequenceExpressionTests.fs
index 8247eaf60e3..263f305f7a5 100644
--- a/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressionTests.fs
+++ b/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressions/SequenceExpressionTests.fs
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
-module Language.SequenceExpressionTests
+module Language.SequenceExpression.SequenceExpressionTests
+open FSharp.Test
open Xunit
open FSharp.Test.Compiler
open FSharp.Test.ScriptHelpers
@@ -467,4 +468,125 @@ let f2 = return! [ 3; 4 ]
|> withDiagnostics [
(Error 748, Line 2, Col 10, Line 2, Col 16, "This construct may only be used within computation expressions. To return a value from an ordinary function simply write the expression without 'return'.");
(Error 748, Line 3, Col 10, Line 3, Col 17, "This construct may only be used within computation expressions. To return a value from an ordinary function simply write the expression without 'return'.")
- ]
\ No newline at end of file
+ ]
+
+[]
+let ``Sequence(SynExpr.Sequential) expressions should be of the form 'seq { ... } lang version 9``() =
+ Fsx """
+{ 1;10 }
+[| { 1;10 } |]
+let a = { 1;10 }
+let b = [| { 1;10 } |]
+let c = [ { 1;10 } ]
+ """
+ |> withOptions [ "--nowarn:0020" ]
+ |> withLangVersion90
+ |> typecheck
+ |> shouldFail
+ |> withDiagnostics [
+ (Error 740, Line 2, Col 1, Line 2, Col 9, "Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }'")
+ (Error 740, Line 3, Col 4, Line 3, Col 12, "Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }'")
+ (Error 740, Line 4, Col 9, Line 4, Col 17, "Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }'")
+ (Error 740, Line 5, Col 12, Line 5, Col 20, "Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }'")
+ (Error 740, Line 6, Col 11, Line 6, Col 19, "Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }'")
+ ]
+
+[]
+let ``Sequence(SynExpr.Sequential) expressions should be of the form 'seq { ... } lang version preview``() =
+ Fsx """
+{ 1;10 }
+[| { 1;10 } |]
+let a = { 1;10 }
+let b = [| { 1;10 } |]
+let c = [ { 1;10 } ]
+ """
+ |> withOptions [ "--nowarn:0020" ]
+ |> withLangVersionPreview
+ |> typecheck
+ |> shouldFail
+ |> withDiagnostics [
+ (Error 740, Line 2, Col 1, Line 2, Col 9, "Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }'")
+ (Error 740, Line 3, Col 4, Line 3, Col 12, "Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }'")
+ (Error 740, Line 4, Col 9, Line 4, Col 17, "Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }'")
+ (Error 740, Line 5, Col 12, Line 5, Col 20, "Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }'")
+ (Error 740, Line 6, Col 11, Line 6, Col 19, "Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }'")
+ ]
+
+// SOURCE=E_SequenceExpressions01.fs # E_SequenceExpressions01.fs
+[]
+let ``E_SequenceExpressions01 lang version 9`` compilation =
+ compilation
+ |> withOptions [ "--nowarn:0020" ]
+ |> withLangVersion90
+ |> typecheck
+ |> shouldSucceed
+
+// SOURCE=E_SequenceExpressions01.fs # E_SequenceExpressions01.fs
+[]
+let ``E_SequenceExpressions01 lang version preview`` compilation =
+ compilation
+ |> withOptions [ "--nowarn:0020" ]
+ |> withLangVersionPreview
+ |> typecheck
+ |> shouldFail
+ |> withDiagnostics [
+ (Warning 3873, Line 1, Col 1, Line 1, Col 10, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 3, Col 1, Line 3, Col 13, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 5, Col 4, Line 5, Col 13, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 7, Col 4, Line 7, Col 16, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 9, Col 9, Line 9, Col 18, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 11, Col 10, Line 11, Col 23, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 13, Col 12, Line 13, Col 21, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 15, Col 13, Line 15, Col 26, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 17, Col 11, Line 17, Col 20, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 19, Col 4, Line 19, Col 13, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 21, Col 10, Line 21, Col 19, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 23, Col 3, Line 23, Col 12, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 25, Col 3, Line 25, Col 16, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 27, Col 9, Line 27, Col 18, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 29, Col 9, Line 29, Col 22, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 31, Col 13, Line 31, Col 22, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 33, Col 13, Line 33, Col 26, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 35, Col 34, Line 35, Col 51, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 37, Col 35, Line 37, Col 52, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 39, Col 10, Line 39, Col 19, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 41, Col 10, Line 41, Col 22, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 45, Col 12, Line 45, Col 20, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 47, Col 13, Line 47, Col 25, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 49, Col 14, Line 49, Col 22, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 51, Col 33, Line 51, Col 50, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 55, Col 12, Line 55, Col 21, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 57, Col 1, Line 57, Col 13, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 59, Col 28, Line 59, Col 34, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 61, Col 44, Line 61, Col 52, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 61, Col 53, Line 61, Col 61, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 61, Col 62, Line 61, Col 71, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 65, Col 17, Line 65, Col 23, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 65, Col 34, Line 65, Col 44, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 67, Col 7, Line 67, Col 13, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 67, Col 15, Line 67, Col 21, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 67, Col 23, Line 67, Col 30, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 69, Col 14, Line 69, Col 22, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 71, Col 24, Line 71, Col 32, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 73, Col 25, Line 73, Col 33, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 74, Col 25, Line 74, Col 33, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ (Warning 3873, Line 76, Col 13, Line 76, Col 20, "This construct is deprecated. Sequence expressions should be of the form 'seq { ... }'")
+ ]
+
+// SOURCE=SequenceExpressions01.fs # SequenceExpressions01.fs
+[]
+let ``SequenceExpressions01 lang version 9`` compilation =
+ compilation
+ |> withOptions [ "--nowarn:0020" ]
+ |> withLangVersion90
+ |> typecheck
+ |> shouldSucceed
+
+// SOURCE=SequenceExpressions01.fs # SequenceExpressions01.fs
+[]
+let ``SequenceExpressions01 lang version preview`` compilation =
+ compilation
+ |> withOptions [ "--nowarn:0020" ]
+ |> withLangVersionPreview
+ |> typecheck
+ |> shouldSucceed
\ No newline at end of file
diff --git a/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressions/SequenceExpressions01.fs b/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressions/SequenceExpressions01.fs
new file mode 100644
index 00000000000..ea1ab603eef
--- /dev/null
+++ b/tests/FSharp.Compiler.ComponentTests/Language/SequenceExpressions/SequenceExpressions01.fs
@@ -0,0 +1,76 @@
+seq { 1..10 }
+
+seq { 1..5..10 }
+
+[| seq { 1..10 } |]
+
+[| seq { 1..5..10 } |]
+
+let a = seq { 1..10 }
+
+let a3 = seq { 1..10..20 }
+
+let b = [| seq { 1..10 } |]
+
+let b3 = [| seq { 1..10..20 } |]
+
+let c = [ seq { 1..10 } ]
+
+[| seq { 1..10 } |]
+
+[| yield seq { 1..10 } |]
+
+[ seq { 1..10 } ]
+
+[ seq { 1..10..10 } ]
+
+[ yield seq { 1..10 } ]
+
+[ yield seq { 1..10..20 } ]
+
+ResizeArray(seq { 1..10 })
+
+ResizeArray(seq { 1..10..20 })
+
+let fw start finish = [ for x in seq { start..finish } -> x ]
+
+let fe start finish = [| for x in seq { start..finish } -> x |]
+
+for x in seq { 1..10 } do ()
+
+for x in seq { 1..5..10 } do ()
+
+let f = Seq.head
+
+let a2 = f (seq { 1..6 })
+
+let a23 = f (seq { 1..6..10 })
+
+let b2 = set (seq { 1..6 })
+
+let f10 start finish = for x in seq { start..finish } do ignore (float x ** float x)
+
+let (..) _ _ = "lol"
+
+let lol1 = seq { 1..10 }
+
+seq { 1..5..10 }
+
+let resultInt = Seq.length (seq {1..8})
+
+let resultInt2 funcInt = Seq.map3 funcInt (seq { 1..8 }) (seq { 2..9 }) (seq { 3..10 })
+
+let verify c = failwith "not implemented"
+
+Seq.splitInto 4 (seq {1..5}) |> verify (seq { 1.. 10 })
+
+seq [ seq {1..4}; seq {5..7}; seq {8..10} ]
+
+Seq.allPairs (seq { 1..7 }) Seq.empty
+
+Seq.allPairs Seq.empty (seq { 1..7 })
+
+let intArr1 = [| yield! seq {1..100}
+ yield! seq {1..100} |]
+
+Array.ofSeq (seq {1..10})
\ No newline at end of file
diff --git a/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs b/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs
index 4ae43434099..e22c58e8a3a 100644
--- a/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs
+++ b/tests/FSharp.Compiler.Service.Tests/PatternMatchCompilationTests.fs
@@ -455,7 +455,7 @@ let r as _ = 10
let s as Id0 = 11
let t as (u) = 12
let v as struct(w, x) = 13, 14
-let y as z : int = 15{set { 'a'..'x' } - set [ 'p'; 'v' ] |> Set.map (sprintf " + %c") |> System.String.Concat}
+let y as z : int = 15{set (seq { 'a'..'x' }) - set [ 'p'; 'v' ] |> Set.map (sprintf " + %c") |> System.String.Concat}
Some p |> eq
Some v |> eq
()
@@ -590,7 +590,7 @@ let _ as r = 10
let Id0 as s = 11
let (t) as u = 12
let struct(w, v) as x = 13, 14
-let (y : int) as z = 15{set { 'a'..'v' } - set [ 'h'; 'q' ] |> Set.map (sprintf " + %c") |> System.String.Concat}
+let (y : int) as z = 15{set (seq { 'a'..'v' }) - set [ 'h'; 'q' ] |> Set.map (sprintf " + %c") |> System.String.Concat}
Some h |> eq
Some q |> eq
Some x |> eq
@@ -917,7 +917,7 @@ let :? z as
[]
let ``As 16 - syntactical precedence matrix testing left with type tests - total patterns`` () =
- let validSet = set { 'a'..'x' } - set [ 'p'; 'q' ] |> Set.map string
+ let validSet = set (seq { 'a'..'x' }) - set [ 'p'; 'q' ] |> Set.map string
let _, checkResults = getParseAndCheckResults70 $"""
let eq<'T> (x:'T option) = () // FS-1093-safe type assert function
let (|Id0|) = ignore
diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule.fs
index c2b0d240372..662a729e28f 100644
--- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule.fs
+++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule.fs
@@ -259,8 +259,8 @@ type ArrayModule() =
[]
member _.Except() =
// integer array
- let intArr1 = [| yield! {1..100}
- yield! {1..100} |]
+ let intArr1 = [| yield! seq {1..100}
+ yield! seq {1..100} |]
let intArr2 = [| 1 .. 10 |]
let expectedIntArr = [| 11 .. 100 |]
diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule2.fs
index ec30e724bbb..5c5afc3c234 100644
--- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule2.fs
+++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ArrayModule2.fs
@@ -372,7 +372,7 @@ type ArrayModule2() =
[]
member this.Of_Seq() =
// integer array
- let resultInt = Array.ofSeq {1..10}
+ let resultInt = Array.ofSeq (seq {1..10})
if resultInt <> [|1..10|] then Assert.Fail()
// string array
diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ListModule.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ListModule.fs
index 9f3ae062d02..8b0fcf507e5 100644
--- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ListModule.fs
+++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ListModule.fs
@@ -346,8 +346,8 @@ type ListModule() =
[]
member _.Except() =
// integer list
- let intList1 = [ yield! {1..100}
- yield! {1..100} ]
+ let intList1 = [ yield! seq {1..100}
+ yield! seq {1..100} ]
let intList2 = [1..10]
let expectedIntList = [11..100]
diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs
index 328574bdac0..3a27d4e7d2a 100644
--- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs
+++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ListModule2.fs
@@ -367,7 +367,7 @@ type ListModule02() =
[]
member this.Of_Seq() =
// integer List
- let resultInt = List.ofSeq {1..10}
+ let resultInt = List.ofSeq (seq {1..10})
Assert.AreEqual([1..10], resultInt)
// string List
diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteSeqFunctions.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteSeqFunctions.fs
index 3b8727fc538..67c5aeba747 100644
--- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteSeqFunctions.fs
+++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/ObsoleteSeqFunctions.fs
@@ -15,14 +15,14 @@ type ObsoleteSeqFunctions() =
// Negative index
for i = -1 downto -10 do
- CheckThrowsArgumentException (fun () -> Seq.nth i { 10 .. 20 } |> ignore)
+ CheckThrowsArgumentException (fun () -> Seq.nth i (seq { 10 .. 20 }) |> ignore)
// Out of range
for i = 11 to 20 do
- CheckThrowsArgumentException (fun () -> Seq.nth i { 10 .. 20 } |> ignore)
+ CheckThrowsArgumentException (fun () -> Seq.nth i (seq { 10 .. 20 }) |> ignore)
// integer Seq
- let resultInt = Seq.nth 3 { 10..20 }
+ let resultInt = Seq.nth 3 (seq { 10..20 })
Assert.AreEqual(13, resultInt)
// string Seq
diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule.fs
index de6f66dd7ec..f2f88933506 100644
--- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule.fs
+++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule.fs
@@ -39,8 +39,8 @@ type SeqModule() =
// empty Seq
VerifySeqsEqual Seq.empty <| Seq.allPairs Seq.empty Seq.empty
- VerifySeqsEqual Seq.empty <| Seq.allPairs { 1..7 } Seq.empty
- VerifySeqsEqual Seq.empty <| Seq.allPairs Seq.empty { 1..7 }
+ VerifySeqsEqual Seq.empty <| Seq.allPairs (seq { 1..7 }) Seq.empty
+ VerifySeqsEqual Seq.empty <| Seq.allPairs Seq.empty (seq { 1..7 })
// null Seq
CheckThrowsArgumentNullException(fun() -> Seq.allPairs null null |> ignore)
@@ -349,9 +349,9 @@ type SeqModule() =
|> Seq.iter ((<||) VerifySeqsEqual)
// int Seq
- verify [[1..4];[5..8]] <| Seq.chunkBySize 4 {1..8}
- verify [[1..4];[5..8];[9..10]] <| Seq.chunkBySize 4 {1..10}
- verify [[1]; [2]; [3]; [4]] <| Seq.chunkBySize 1 {1..4}
+ verify [[1..4];[5..8]] <| Seq.chunkBySize 4 (seq {1..8})
+ verify [[1..4];[5..8];[9..10]] <| Seq.chunkBySize 4 (seq {1..10})
+ verify [[1]; [2]; [3]; [4]] <| Seq.chunkBySize 1 (seq {1..4})
Seq.chunkBySize 2 (Seq.initInfinite id)
|> Seq.take 3
@@ -372,8 +372,8 @@ type SeqModule() =
CheckThrowsArgumentNullException (fun () -> Seq.chunkBySize 3 nullSeq |> ignore)
// invalidArg
- CheckThrowsArgumentException (fun () -> Seq.chunkBySize 0 {1..10} |> ignore)
- CheckThrowsArgumentException (fun () -> Seq.chunkBySize -1 {1..10} |> ignore)
+ CheckThrowsArgumentException (fun () -> Seq.chunkBySize 0 (seq {1..10}) |> ignore)
+ CheckThrowsArgumentException (fun () -> Seq.chunkBySize -1 (seq {1..10}) |> ignore)
()
@@ -385,12 +385,12 @@ type SeqModule() =
|> Seq.iter ((<||) VerifySeqsEqual)
// int Seq
- Seq.splitInto 3 {1..10} |> verify (seq [ {1..4}; {5..7}; {8..10} ])
- Seq.splitInto 3 {1..11} |> verify (seq [ {1..4}; {5..8}; {9..11} ])
- Seq.splitInto 3 {1..12} |> verify (seq [ {1..4}; {5..8}; {9..12} ])
+ Seq.splitInto 3 (seq {1..10}) |> verify (seq [ seq {1..4}; seq {5..7}; seq {8..10} ])
+ Seq.splitInto 3 (seq {1..11}) |> verify (seq [ seq {1..4}; seq {5..8}; seq {9..11} ])
+ Seq.splitInto 3 (seq {1..12}) |> verify (seq [ seq {1..4}; seq {5..8}; seq {9..12} ])
- Seq.splitInto 4 {1..5} |> verify (seq [ [1..2]; [3]; [4]; [5] ])
- Seq.splitInto 20 {1..4} |> verify (seq [ [1]; [2]; [3]; [4] ])
+ Seq.splitInto 4 (seq {1..5}) |> verify (seq [ [1..2]; [3]; [4]; [5] ])
+ Seq.splitInto 20 (seq {1..4}) |> verify (seq [ [1]; [2]; [3]; [4] ])
// string Seq
Seq.splitInto 3 ["a";"b";"c";"d";"e"] |> verify ([ ["a"; "b"]; ["c";"d"]; ["e"] ])
@@ -586,10 +586,10 @@ type SeqModule() =
[]
member _.Except() =
// integer Seq
- let intSeq1 = seq { yield! {1..100}
- yield! {1..100} }
- let intSeq2 = {1..10}
- let expectedIntSeq = {11..100}
+ let intSeq1 = seq { yield! seq {1..100}
+ yield! seq {1..100} }
+ let intSeq2 = seq {1..10}
+ let expectedIntSeq = seq {11..100}
VerifySeqsEqual expectedIntSeq <| Seq.except intSeq2 intSeq1
@@ -609,7 +609,7 @@ type SeqModule() =
// empty Seq
let emptyIntSeq = Seq.empty
- VerifySeqsEqual {1..100} <| Seq.except emptyIntSeq intSeq1
+ VerifySeqsEqual (seq {1..100}) <| Seq.except emptyIntSeq intSeq1
VerifySeqsEqual emptyIntSeq <| Seq.except intSeq1 emptyIntSeq
VerifySeqsEqual emptyIntSeq <| Seq.except emptyIntSeq emptyIntSeq
VerifySeqsEqual emptyIntSeq <| Seq.except intSeq1 intSeq1
diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs
index 8412b999b5d..db3b8a3adcc 100644
--- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs
+++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs
@@ -479,7 +479,7 @@ type SeqModule2() =
member _.Length() =
// integer seq
- let resultInt = Seq.length {1..8}
+ let resultInt = Seq.length (seq {1..8})
if resultInt <> 8 then Assert.Fail()
// string Seq
@@ -505,7 +505,7 @@ type SeqModule2() =
| _ when x % 2 = 0 -> 10*x
| _ -> x
- let resultInt = Seq.map funcInt { 1..10 }
+ let resultInt = Seq.map funcInt (seq { 1..10 })
let expectedint = seq [1;20;3;40;5;60;7;80;9;100]
VerifySeqsEqual expectedint resultInt
@@ -531,7 +531,7 @@ type SeqModule2() =
member _.Map2() =
// integer Seq
let funcInt x y = x+y
- let resultInt = Seq.map2 funcInt { 1..10 } {2..2..20}
+ let resultInt = Seq.map2 funcInt (seq { 1..10 }) (seq {2..2..20})
let expectedint = seq [3;6;9;12;15;18;21;24;27;30]
VerifySeqsEqual expectedint resultInt
@@ -558,16 +558,16 @@ type SeqModule2() =
member _.Map3() =
// Integer seq
let funcInt a b c = (a + b) * c
- let resultInt = Seq.map3 funcInt { 1..8 } { 2..9 } { 3..10 }
+ let resultInt = Seq.map3 funcInt (seq { 1..8 }) (seq { 2..9 }) (seq { 3..10 })
let expectedInt = seq [9; 20; 35; 54; 77; 104; 135; 170]
VerifySeqsEqual expectedInt resultInt
// First seq is shorter
- VerifySeqsEqual (seq [9; 20]) (Seq.map3 funcInt { 1..2 } { 2..9 } { 3..10 })
+ VerifySeqsEqual (seq [9; 20]) (Seq.map3 funcInt (seq { 1..2 }) (seq { 2..9 }) (seq { 3..10 }))
// Second seq is shorter
- VerifySeqsEqual (seq [9; 20; 35]) (Seq.map3 funcInt { 1..8 } { 2..4 } { 3..10 })
+ VerifySeqsEqual (seq [9; 20; 35]) (Seq.map3 funcInt (seq { 1..8 }) (seq { 2..4 }) (seq { 3..10 }))
// Third seq is shorter
- VerifySeqsEqual (seq [9; 20; 35; 54]) (Seq.map3 funcInt { 1..8 } { 2..6 } { 3..6 })
+ VerifySeqsEqual (seq [9; 20; 35; 54]) (Seq.map3 funcInt (seq { 1..8 }) (seq { 2..6 }) (seq { 3..6 }))
// String seq
let funcStr a b c = a + b + c
@@ -812,7 +812,7 @@ type SeqModule2() =
member _.Collect() =
// integer Seq
let funcInt x = seq [x+1]
- let resultInt = Seq.collect funcInt { 1..10 }
+ let resultInt = Seq.collect funcInt (seq { 1..10 })
let expectedint = seq {2..11}
@@ -843,7 +843,7 @@ type SeqModule2() =
// integer Seq
let funcInt x y = x+y
- let resultInt = Seq.mapi funcInt { 10..2..20 }
+ let resultInt = Seq.mapi funcInt (seq { 10..2..20 })
let expectedint = seq [10;13;16;19;22;25]
VerifySeqsEqual expectedint resultInt
@@ -871,7 +871,7 @@ type SeqModule2() =
member _.Mapi2() =
// integer Seq
let funcInt x y z = x+y+z
- let resultInt = Seq.mapi2 funcInt { 1..10 } {2..2..20}
+ let resultInt = Seq.mapi2 funcInt (seq { 1..10 }) (seq {2..2..20})
let expectedint = seq [3;7;11;15;19;23;27;31;35;39]
VerifySeqsEqual expectedint resultInt
@@ -907,7 +907,7 @@ type SeqModule2() =
member _.Indexed() =
// integer Seq
- let resultInt = Seq.indexed { 10..2..20 }
+ let resultInt = Seq.indexed (seq { 10..2..20 })
let expectedint = seq [(0,10);(1,12);(2,14);(3,16);(4,18);(5,20)]
VerifySeqsEqual expectedint resultInt
@@ -931,7 +931,7 @@ type SeqModule2() =
[]
member _.Max() =
// integer Seq
- let resultInt = Seq.max { 10..20 }
+ let resultInt = Seq.max (seq { 10..20 })
Assert.AreEqual(20,resultInt)
@@ -954,7 +954,7 @@ type SeqModule2() =
// integer Seq
let funcInt x = x % 8
- let resultInt = Seq.maxBy funcInt { 2..2..20 }
+ let resultInt = Seq.maxBy funcInt (seq { 2..2..20 })
Assert.AreEqual(6,resultInt)
// string Seq
@@ -976,7 +976,7 @@ type SeqModule2() =
// integer Seq
let funcInt x = x % 8
- let resultInt = Seq.minBy funcInt { 2..2..20 }
+ let resultInt = Seq.minBy funcInt (seq { 2..2..20 })
Assert.AreEqual(8,resultInt)
// string Seq
@@ -998,7 +998,7 @@ type SeqModule2() =
member _.Min() =
// integer Seq
- let resultInt = Seq.min { 10..20 }
+ let resultInt = Seq.min (seq { 10..20 })
Assert.AreEqual(10,resultInt)
// string Seq
@@ -1017,7 +1017,7 @@ type SeqModule2() =
[]
member _.Item() =
// integer Seq
- let resultInt = Seq.item 3 { 10..20 }
+ let resultInt = Seq.item 3 (seq { 10..20 })
Assert.AreEqual(13, resultInt)
// string Seq
@@ -1033,11 +1033,11 @@ type SeqModule2() =
// Negative index
for i = -1 downto -10 do
- CheckThrowsArgumentException (fun () -> Seq.item i { 10 .. 20 } |> ignore)
+ CheckThrowsArgumentException (fun () -> Seq.item i (seq { 10 .. 20 }) |> ignore)
// Out of range
for i = 11 to 20 do
- CheckThrowsArgumentException (fun () -> Seq.item i { 10 .. 20 } |> ignore)
+ CheckThrowsArgumentException (fun () -> Seq.item i (seq { 10 .. 20 }) |> ignore)
[]
member _.``item should fail with correct number of missing elements``() =
@@ -1057,7 +1057,7 @@ type SeqModule2() =
member _.Of_Array() =
// integer Seq
let resultInt = Seq.ofArray [|1..10|]
- let expectedInt = {1..10}
+ let expectedInt = seq {1..10}
VerifySeqsEqual expectedInt resultInt
@@ -1076,7 +1076,7 @@ type SeqModule2() =
member _.Of_List() =
// integer Seq
let resultInt = Seq.ofList [1..10]
- let expectedInt = {1..10}
+ let expectedInt = seq {1..10}
VerifySeqsEqual expectedInt resultInt
@@ -1095,7 +1095,7 @@ type SeqModule2() =
[]
member _.Pairwise() =
// integer Seq
- let resultInt = Seq.pairwise {1..3}
+ let resultInt = Seq.pairwise (seq {1..3})
let expectedInt = seq [1,2;2,3]
@@ -1182,7 +1182,7 @@ type SeqModule2() =
member _.Scan() =
// integer Seq
let funcInt x y = x+y
- let resultInt = Seq.scan funcInt 9 {1..10}
+ let resultInt = Seq.scan funcInt 9 (seq {1..10})
let expectedInt = seq [9;10;12;15;19;24;30;37;45;54;64]
VerifySeqsEqual expectedInt resultInt
@@ -1207,7 +1207,7 @@ type SeqModule2() =
member _.ScanBack() =
// integer Seq
let funcInt x y = x+y
- let resultInt = Seq.scanBack funcInt { 1..10 } 9
+ let resultInt = Seq.scanBack funcInt (seq { 1..10 }) 9
let expectedInt = seq [64;63;61;58;54;49;43;36;28;19;9]
VerifySeqsEqual expectedInt resultInt
@@ -1313,7 +1313,7 @@ type SeqModule2() =
// integer Seq
let resultInt = Seq.sort (seq [1;3;2;4;6;5;7])
- let expectedInt = {1..7}
+ let expectedInt = seq {1..7}
VerifySeqsEqual expectedInt resultInt
// string Seq
@@ -1960,7 +1960,7 @@ type SeqModule2() =
[]
member _.tryItem() =
// integer Seq
- let resultInt = Seq.tryItem 3 { 10..20 }
+ let resultInt = Seq.tryItem 3 (seq { 10..20 })
Assert.AreEqual(Some(13), resultInt)
// string Seq
@@ -1976,11 +1976,11 @@ type SeqModule2() =
CheckThrowsArgumentNullException (fun () -> Seq.tryItem 3 nullSeq |> ignore)
// Negative index
- let resultNegativeIndex = Seq.tryItem -1 { 10..20 }
+ let resultNegativeIndex = Seq.tryItem -1 (seq { 10..20 })
Assert.AreEqual(None, resultNegativeIndex)
// Index greater than length
- let resultIndexGreater = Seq.tryItem 31 { 10..20 }
+ let resultIndexGreater = Seq.tryItem 31 (seq { 10..20 })
Assert.AreEqual(None, resultIndexGreater)
[]
diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/PrimTypes.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/PrimTypes.fs
index 8e24be62850..68692f65c67 100644
--- a/tests/FSharp.Core.UnitTests/FSharp.Core/PrimTypes.fs
+++ b/tests/FSharp.Core.UnitTests/FSharp.Core/PrimTypes.fs
@@ -821,7 +821,7 @@ module internal RangeTestsHelpers =
enumerator.Current |> ignore
let inline exceptions zero one two =
- Assert.Throws (typeof, (fun () -> {one .. zero .. two} |> Seq.length |> ignore)) |> ignore
+ Assert.Throws (typeof, (fun () -> seq {one .. zero .. two} |> Seq.length |> ignore)) |> ignore
Assert.Throws (typeof, (fun () -> [one .. zero .. two] |> List.length |> ignore)) |> ignore
Assert.Throws (typeof, (fun () -> [|one .. zero .. two|] |> Array.length |> ignore)) |> ignore
@@ -831,10 +831,10 @@ module internal RangeTestsHelpers =
Assert.Throws (typeof, (fun () -> regressionExceptionAfterEndVariableStepIntegralRange zero two)) |> ignore
let inline common (min0, min1, min2, min3) (max0, max1, max2, max3) (zero, one, two, three) =
- Assert.AreEqual (seq {yield min0; yield min1; yield min2; yield min3}, {min0 .. min3})
- Assert.AreEqual (seq {min0; min1; min2; min3}, {min0 .. one .. min3})
- Assert.AreEqual (seq {min0; min2}, {min0 .. two .. min3})
- Assert.AreEqual (seq {min0; min3}, {min0 .. three .. min3})
+ Assert.AreEqual (seq {yield min0; yield min1; yield min2; yield min3}, seq {min0 .. min3})
+ Assert.AreEqual (seq {min0; min1; min2; min3}, seq {min0 .. one .. min3})
+ Assert.AreEqual (seq {min0; min2}, seq {min0 .. two .. min3})
+ Assert.AreEqual (seq {min0; min3}, seq {min0 .. three .. min3})
Assert.AreEqual ([min0; min1; min2; min3], [min0 .. min3])
Assert.AreEqual ([min0; min1; min2; min3], [min0 .. one .. min3])
@@ -846,10 +846,10 @@ module internal RangeTestsHelpers =
Assert.AreEqual ([|min0; min2|], [|min0 .. two .. min3|])
Assert.AreEqual ([|min0; min3|], [|min0 .. three .. min3|])
- Assert.AreEqual (seq {yield max3; yield max2; yield max1; yield max0}, {max3 .. max0})
- Assert.AreEqual (seq {max3; max2; max1; max0}, {max3 .. one .. max0})
- Assert.AreEqual (seq {max3; max1}, {max3 .. two .. max0})
- Assert.AreEqual (seq {max3; max0}, {max3 .. three .. max0})
+ Assert.AreEqual (seq {yield max3; yield max2; yield max1; yield max0}, seq {max3 .. max0})
+ Assert.AreEqual (seq {max3; max2; max1; max0}, seq {max3 .. one .. max0})
+ Assert.AreEqual (seq {max3; max1}, seq {max3 .. two .. max0})
+ Assert.AreEqual (seq {max3; max0}, seq {max3 .. three .. max0})
Assert.AreEqual ([max3; max2; max1; max0], [max3 .. max0])
Assert.AreEqual ([max3; max2; max1; max0], [max3 .. one .. max0])
@@ -861,10 +861,10 @@ module internal RangeTestsHelpers =
Assert.AreEqual ([|max3; max1|], [|max3 .. two .. max0|])
Assert.AreEqual ([|max3; max0|], [|max3 .. three .. max0|])
- Assert.AreEqual (Seq.empty, {max0 .. min0})
- Assert.AreEqual (Seq.empty, {max0 .. one .. min0})
- Assert.AreEqual (Seq.empty, {max0 .. two .. min0})
- Assert.AreEqual (Seq.empty, {max0 .. three .. min0})
+ Assert.AreEqual (Seq.empty, seq {max0 .. min0})
+ Assert.AreEqual (Seq.empty, seq {max0 .. one .. min0})
+ Assert.AreEqual (Seq.empty, seq {max0 .. two .. min0})
+ Assert.AreEqual (Seq.empty, seq {max0 .. three .. min0})
Assert.AreEqual ([], [max0 .. min0])
Assert.AreEqual ([], [max0 .. one .. min0])
@@ -880,8 +880,8 @@ module internal RangeTestsHelpers =
// tests for singleStepRangeEnumerator, as it only is used if start and/or end are not the
// minimum or maximum of the number range and it is counting by 1s
- Assert.AreEqual (seq {min1; min2; min3}, {min1 .. min3})
- Assert.AreEqual (seq {max3; max2; max1}, {max3 .. max1})
+ Assert.AreEqual (seq {min1; min2; min3}, seq {min1 .. min3})
+ Assert.AreEqual (seq {max3; max2; max1}, seq {max3 .. max1})
Assert.AreEqual ([min1; min2; min3], [min1 .. min3])
Assert.AreEqual ([max3; max2; max1], [max3 .. max1])
@@ -903,10 +903,10 @@ module internal RangeTestsHelpers =
common (min0, min1, min2, min3) (max0, max1, max2, max3) (zero, one, two, three)
- Assert.AreEqual (seq { min0; min0 + max0; min0 + max0 + max0 }, {min0 .. max0 .. max0})
- Assert.AreEqual (seq { min0; min0 + max1; min0 + max1 + max1 }, {min0 .. max1 .. max0})
- Assert.AreEqual (seq { min0; min0 + max2; min0 + max2 + max2 }, {min0 .. max2 .. max0})
- Assert.AreEqual (seq { min0; min0 + max3; min0 + max3 + max3 }, {min0 .. max3 .. max0})
+ Assert.AreEqual (seq { min0; min0 + max0; min0 + max0 + max0 }, seq {min0 .. max0 .. max0})
+ Assert.AreEqual (seq { min0; min0 + max1; min0 + max1 + max1 }, seq {min0 .. max1 .. max0})
+ Assert.AreEqual (seq { min0; min0 + max2; min0 + max2 + max2 }, seq {min0 .. max2 .. max0})
+ Assert.AreEqual (seq { min0; min0 + max3; min0 + max3 + max3 }, seq {min0 .. max3 .. max0})
Assert.AreEqual ([ min0; min0 + max0; min0 + max0 + max0 ], [min0 .. max0 .. max0])
Assert.AreEqual ([ min0; min0 + max1; min0 + max1 + max1 ], [min0 .. max1 .. max0])
@@ -918,9 +918,9 @@ module internal RangeTestsHelpers =
Assert.AreEqual ([| min0; min0 + max2; min0 + max2 + max2 |], [|min0 .. max2 .. max0|])
Assert.AreEqual ([| min0; min0 + max3; min0 + max3 + max3 |], [|min0 .. max3 .. max0|])
- Assert.AreEqual (seq {min3; min2; min1; min0}, {min3 .. -one .. min0})
- Assert.AreEqual (seq {min3; min1}, {min3 .. -two .. min0})
- Assert.AreEqual (seq {min3; min0}, {min3 .. -three .. min0})
+ Assert.AreEqual (seq {min3; min2; min1; min0}, seq {min3 .. -one .. min0})
+ Assert.AreEqual (seq {min3; min1}, seq {min3 .. -two .. min0})
+ Assert.AreEqual (seq {min3; min0}, seq {min3 .. -three .. min0})
Assert.AreEqual ([min3; min2; min1; min0], [min3 .. -one .. min0])
Assert.AreEqual ([min3; min1], [min3 .. -two .. min0])
@@ -930,9 +930,9 @@ module internal RangeTestsHelpers =
Assert.AreEqual ([|min3; min1|], [|min3 .. -two .. min0|])
Assert.AreEqual ([|min3; min0|], [|min3 .. -three .. min0|])
- Assert.AreEqual (seq {max0; max1; max2; max3}, {max0 .. -one .. max3})
- Assert.AreEqual (seq {max0; max2}, {max0 .. -two .. max3})
- Assert.AreEqual (seq {max0; max3}, {max0 .. -three .. max3})
+ Assert.AreEqual (seq {max0; max1; max2; max3}, seq {max0 .. -one .. max3})
+ Assert.AreEqual (seq {max0; max2}, seq {max0 .. -two .. max3})
+ Assert.AreEqual (seq {max0; max3}, seq {max0 .. -three .. max3})
Assert.AreEqual ([max0; max1; max2; max3], [max0 .. -one .. max3])
Assert.AreEqual ([max0; max2], [max0 .. -two .. max3])
@@ -942,9 +942,9 @@ module internal RangeTestsHelpers =
Assert.AreEqual ([|max0; max2|], [|max0 .. -two .. max3|])
Assert.AreEqual ([|max0; max3|], [|max0 .. -three .. max3|])
- Assert.AreEqual (Seq.empty, {min0 .. -one .. max0})
- Assert.AreEqual (Seq.empty, {min0 .. -two .. max0})
- Assert.AreEqual (Seq.empty, {min0 .. -three .. max0})
+ Assert.AreEqual (Seq.empty, seq {min0 .. -one .. max0})
+ Assert.AreEqual (Seq.empty, seq {min0 .. -two .. max0})
+ Assert.AreEqual (Seq.empty, seq {min0 .. -three .. max0})
Assert.AreEqual ([], [min0 .. -one .. max0])
Assert.AreEqual ([], [min0 .. -two .. max0])
@@ -954,10 +954,10 @@ module internal RangeTestsHelpers =
Assert.AreEqual ([||], [|min0 .. -two .. max0|])
Assert.AreEqual ([||], [|min0 .. -three .. max0|])
- Assert.AreEqual (seq {max0; max0 + min0}, {max0 .. min0 .. min0})
- Assert.AreEqual (seq {max0; max0 + min1; max0 + min1 + min1 }, {max0 .. min1 .. min0})
- Assert.AreEqual (seq {max0; max0 + min2; max0 + min2 + min2 }, {max0 .. min2 .. min0})
- Assert.AreEqual (seq {max0; max0 + min3; max0 + min3 + min3 }, {max0 .. min3 .. min0})
+ Assert.AreEqual (seq {max0; max0 + min0}, seq {max0 .. min0 .. min0})
+ Assert.AreEqual (seq {max0; max0 + min1; max0 + min1 + min1 }, seq {max0 .. min1 .. min0})
+ Assert.AreEqual (seq {max0; max0 + min2; max0 + min2 + min2 }, seq {max0 .. min2 .. min0})
+ Assert.AreEqual (seq {max0; max0 + min3; max0 + min3 + min3 }, seq {max0 .. min3 .. min0})
Assert.AreEqual ([max0; max0 + min0], [max0 .. min0 .. min0])
Assert.AreEqual ([max0; max0 + min1; max0 + min1 + min1 ], [max0 .. min1 .. min0])
@@ -983,10 +983,10 @@ module internal RangeTestsHelpers =
common (min0, min1, min2, min3) (max0, max1, max2, max3) (zero, one, two, three)
- Assert.AreEqual (seq {yield min0; yield min0 + max0}, {min0 .. max0 .. max0})
- Assert.AreEqual (seq {min0; min0 + max1}, {min0 .. max1 .. max0})
- Assert.AreEqual (seq {min0; min0 + max2}, {min0 .. max2 .. max0})
- Assert.AreEqual (seq {min0; min0 + max3}, {min0 .. max3 .. max0})
+ Assert.AreEqual (seq {yield min0; yield min0 + max0}, seq {min0 .. max0 .. max0})
+ Assert.AreEqual (seq {min0; min0 + max1}, seq {min0 .. max1 .. max0})
+ Assert.AreEqual (seq {min0; min0 + max2}, seq {min0 .. max2 .. max0})
+ Assert.AreEqual (seq {min0; min0 + max3}, seq {min0 .. max3 .. max0})
Assert.AreEqual ([min0; min0 + max0], [min0 .. max0 .. max0])
Assert.AreEqual ([min0; min0 + max1], [min0 .. max1 .. max0])
@@ -1064,15 +1064,15 @@ module RangeTests =
Assert.AreEqual(256, let mutable c = 0 in for _ in System.SByte.MinValue..1y..System.SByte.MaxValue do c <- c + 1 done; c)
Assert.AreEqual(256, let mutable c = 0 in for _ in System.SByte.MaxValue .. -1y .. System.SByte.MinValue do c <- c + 1 done; c)
- Assert.AreEqual(allSBytesSeq, {System.SByte.MinValue..System.SByte.MaxValue})
+ Assert.AreEqual(allSBytesSeq, seq {System.SByte.MinValue..System.SByte.MaxValue})
Assert.AreEqual(allSBytesList, [System.SByte.MinValue..System.SByte.MaxValue])
Assert.AreEqual(allSBytesArray, [|System.SByte.MinValue..System.SByte.MaxValue|])
- Assert.AreEqual(allSBytesSeq, {System.SByte.MinValue..1y..System.SByte.MaxValue})
+ Assert.AreEqual(allSBytesSeq, seq {System.SByte.MinValue..1y..System.SByte.MaxValue})
Assert.AreEqual(allSBytesList, [System.SByte.MinValue..1y..System.SByte.MaxValue])
Assert.AreEqual(allSBytesArray, [|System.SByte.MinValue..1y..System.SByte.MaxValue|])
- Assert.AreEqual(Seq.rev allSBytesSeq, {System.SByte.MaxValue .. -1y .. System.SByte.MinValue})
+ Assert.AreEqual(Seq.rev allSBytesSeq, seq {System.SByte.MaxValue .. -1y .. System.SByte.MinValue})
Assert.AreEqual(List.rev allSBytesList, [System.SByte.MaxValue .. -1y .. System.SByte.MinValue])
Assert.AreEqual(Array.rev allSBytesArray, [|System.SByte.MaxValue .. -1y .. System.SByte.MinValue|])
@@ -1083,11 +1083,11 @@ module RangeTests =
Assert.AreEqual(256, let mutable c = 0 in for _ in System.Byte.MinValue..System.Byte.MaxValue do c <- c + 1 done; c)
Assert.AreEqual(256, let mutable c = 0 in for _ in System.Byte.MinValue..1uy..System.Byte.MaxValue do c <- c + 1 done; c)
- Assert.AreEqual(allBytesSeq, {System.Byte.MinValue..System.Byte.MaxValue})
+ Assert.AreEqual(allBytesSeq, seq {System.Byte.MinValue..System.Byte.MaxValue})
Assert.AreEqual(allBytesList, [System.Byte.MinValue..System.Byte.MaxValue])
Assert.AreEqual(allBytesArray, [|System.Byte.MinValue..System.Byte.MaxValue|])
- Assert.AreEqual(allBytesSeq, {System.Byte.MinValue..1uy..System.Byte.MaxValue})
+ Assert.AreEqual(allBytesSeq, seq {System.Byte.MinValue..1uy..System.Byte.MaxValue})
Assert.AreEqual(allBytesList, [System.Byte.MinValue..1uy..System.Byte.MaxValue])
Assert.AreEqual(allBytesArray, [|System.Byte.MinValue..1uy..System.Byte.MaxValue|])
@@ -1141,15 +1141,15 @@ module RangeTests =
Assert.AreEqual(256, let mutable c = 0 in for _ in min0..one..max0 do c <- c + 1 done; c)
Assert.AreEqual(256, let mutable c = 0 in for _ in max0 .. -one .. min0 do c <- c + 1 done; c)
- Assert.AreEqual(allSBytesSeq, {min0..max0})
+ Assert.AreEqual(allSBytesSeq, seq {min0..max0})
Assert.AreEqual(allSBytesList, [min0..max0])
Assert.AreEqual(allSBytesArray, [|min0..max0|])
- Assert.AreEqual(allSBytesSeq, {min0..one..max0})
+ Assert.AreEqual(allSBytesSeq, seq {min0..one..max0})
Assert.AreEqual(allSBytesList, [min0..one..max0])
Assert.AreEqual(allSBytesArray, [|min0..one..max0|])
- Assert.AreEqual(Seq.rev allSBytesSeq, {max0 .. -one .. min0})
+ Assert.AreEqual(Seq.rev allSBytesSeq, seq {max0 .. -one .. min0})
Assert.AreEqual(List.rev allSBytesList, [max0 .. -one .. min0])
Assert.AreEqual(Array.rev allSBytesArray, [|max0 .. -one .. min0|])
@@ -1160,11 +1160,11 @@ module RangeTests =
Assert.AreEqual(256, let mutable c = 0 in for _ in min0..max0 do c <- c + 1 done; c)
Assert.AreEqual(256, let mutable c = 0 in for _ in min0..one..max0 do c <- c + 1 done; c)
- Assert.AreEqual(allBytesSeq, {min0..max0})
+ Assert.AreEqual(allBytesSeq, seq {min0..max0})
Assert.AreEqual(allBytesList, [min0..max0])
Assert.AreEqual(allBytesArray, [|min0..max0|])
- Assert.AreEqual(allBytesSeq, {min0..one..max0})
+ Assert.AreEqual(allBytesSeq, seq {min0..one..max0})
Assert.AreEqual(allBytesList, [min0..one..max0])
Assert.AreEqual(allBytesArray, [|min0..one..max0|])
diff --git a/tests/FSharp.Core.UnitTests/TestFrameworkHelpers.fs b/tests/FSharp.Core.UnitTests/TestFrameworkHelpers.fs
index d5fe22cc3b3..31a699ae586 100644
--- a/tests/FSharp.Core.UnitTests/TestFrameworkHelpers.fs
+++ b/tests/FSharp.Core.UnitTests/TestFrameworkHelpers.fs
@@ -72,7 +72,7 @@ module private Impl =
let ub = a1.GetUpperBound(0)
if lb <> a2.GetLowerBound(0) || ub <> a2.GetUpperBound(0) then false
else
- {lb..ub} |> Seq.forall(fun i -> equals (a1.GetValue(i)) (a2.GetValue(i)))
+ seq {lb..ub} |> Seq.forall(fun i -> equals (a1.GetValue(i)) (a2.GetValue(i)))
| _ ->
Object.Equals(expected, actual)
diff --git a/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingSeq.fs b/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingSeq.fs
new file mode 100644
index 00000000000..e9a5783bbb2
--- /dev/null
+++ b/vsintegration/src/FSharp.Editor/CodeFixes/AddMissingSeq.fs
@@ -0,0 +1,77 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+namespace Microsoft.VisualStudio.FSharp.Editor
+
+open System.Collections.Immutable
+open System.Composition
+open FSharp.Compiler.Syntax
+open FSharp.Compiler.Text
+open Microsoft.CodeAnalysis.CodeFixes
+open Microsoft.CodeAnalysis.Text
+open CancellableTasks
+
+[]
+[]
+type internal AddMissingSeqCodeFixProvider() =
+ inherit CodeFixProvider()
+
+ static let title = SR.AddMissingSeq()
+ static let fixableDiagnosticIds = ImmutableArray.Create("FS3873", "FS0740")
+
+ override _.FixableDiagnosticIds = fixableDiagnosticIds
+ override this.RegisterCodeFixesAsync context = context.RegisterFsharpFix this
+ override this.GetFixAllProvider() = this.RegisterFsharpFixAll()
+
+ interface IFSharpCodeFixProvider with
+ member _.GetCodeFixIfAppliesAsync context =
+ cancellableTask {
+ let! sourceText = context.GetSourceTextAsync()
+ let! parseFileResults = context.Document.GetFSharpParseResultsAsync(nameof AddMissingSeqCodeFixProvider)
+
+ let getSourceLineStr line =
+ sourceText.Lines[Line.toZ line].ToString()
+
+ let range =
+ RoslynHelpers.TextSpanToFSharpRange(context.Document.FilePath, context.Span, sourceText)
+
+ let needsParens =
+ (range.Start, parseFileResults.ParseTree)
+ ||> ParsedInput.exists (fun path node ->
+ match path, node with
+ | SyntaxNode.SynExpr outer :: _, SyntaxNode.SynExpr(expr & SynExpr.ComputationExpr _) when
+ expr.Range |> Range.equals range
+ ->
+ let seqRange =
+ range
+ |> Range.withEnd (Position.mkPos range.Start.Line (range.Start.Column + 3))
+
+ let inner =
+ SynExpr.App(
+ ExprAtomicFlag.NonAtomic,
+ false,
+ SynExpr.Ident(Ident(nameof seq, seqRange)),
+ expr,
+ Range.unionRanges seqRange expr.Range
+ )
+
+ let outer =
+ match outer with
+ | SynExpr.App(flag, isInfix, funcExpr, _, outerAppRange) ->
+ SynExpr.App(flag, isInfix, funcExpr, inner, outerAppRange)
+ | outer -> outer
+
+ inner
+ |> SynExpr.shouldBeParenthesizedInContext getSourceLineStr (SyntaxNode.SynExpr outer :: path)
+ | _ -> false)
+
+ let text = sourceText.ToString(TextSpan(context.Span.Start, context.Span.Length))
+ let newText = if needsParens then $"(seq {text})" else $"seq {text}"
+
+ return
+ ValueSome
+ {
+ Name = CodeFix.AddMissingSeq
+ Message = title
+ Changes = [ TextChange(context.Span, newText) ]
+ }
+ }
diff --git a/vsintegration/src/FSharp.Editor/Common/Constants.fs b/vsintegration/src/FSharp.Editor/Common/Constants.fs
index 822af01d16a..24ee22eb433 100644
--- a/vsintegration/src/FSharp.Editor/Common/Constants.fs
+++ b/vsintegration/src/FSharp.Editor/Common/Constants.fs
@@ -208,3 +208,6 @@ module internal CodeFix =
[]
let RemoveUnnecessaryParentheses = "RemoveUnnecessaryParentheses"
+
+ []
+ let AddMissingSeq = "AddMissingSeq"
diff --git a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
index 37bb02d43d2..2ec608dda20 100644
--- a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
+++ b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
@@ -141,6 +141,7 @@
+
diff --git a/vsintegration/src/FSharp.Editor/FSharp.Editor.resx b/vsintegration/src/FSharp.Editor/FSharp.Editor.resx
index 26b96dcc405..fac57e8b469 100644
--- a/vsintegration/src/FSharp.Editor/FSharp.Editor.resx
+++ b/vsintegration/src/FSharp.Editor/FSharp.Editor.resx
@@ -359,6 +359,9 @@ Use live (unsaved) buffers for analysis
Remove unnecessary parentheses
+
+ Add missing 'seq'
+
Remarks:
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf
index 421cc037111..7f7c1064aad 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.cs.xlf
@@ -17,6 +17,11 @@
Přidat chybějící parametr člena instance
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
Přidejte klíčové slovo new.
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf
index ff2a415b3a0..4117ecceddc 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.de.xlf
@@ -17,6 +17,11 @@
Fehlenden Instanzmemberparameter hinzufügen
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
Schlüsselwort "new" hinzufügen
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf
index 5df84b54acc..729a252061a 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.es.xlf
@@ -17,6 +17,11 @@
Agregar parámetro de miembro de instancia que falta
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
Agregar "nueva" palabra clave
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf
index efe15d65037..a49ba5d1a13 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.fr.xlf
@@ -17,6 +17,11 @@
Ajouter un paramètre de membre d’instance manquant
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
Ajouter le mot clé 'new'
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf
index ca32c029946..0f82d483df8 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.it.xlf
@@ -17,6 +17,11 @@
Aggiungi parametro membro di istanza mancante
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
Aggiungi la parola chiave 'new'
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf
index 44ca609e1cd..71c981ec17c 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ja.xlf
@@ -17,6 +17,11 @@
見つからないインスタンス メンバー パラメーターを追加する
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
'new' キーワードを追加する
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf
index 66cfbeed575..776efa37ca0 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ko.xlf
@@ -17,6 +17,11 @@
누락된 인스턴스 멤버 매개 변수 추가
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
'new' 키워드 추가
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf
index 1675887bd6d..d4b1c40cd09 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pl.xlf
@@ -17,6 +17,11 @@
Dodaj brakujący parametr składowej wystąpienia
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
Dodaj słowo kluczowe „new”
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf
index f6770d970de..d743e4f549d 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.pt-BR.xlf
@@ -17,6 +17,11 @@
Adicionar parâmetro de membro de instância ausente
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
Adicionar a palavra-chave 'new'
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf
index bc8554237a8..623dbc446f3 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.ru.xlf
@@ -17,6 +17,11 @@
Добавить отсутствующий параметр экземплярного элемента
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
Добавить ключевое слово "new"
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf
index cf2198ba7d3..d652ca45127 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.tr.xlf
@@ -17,6 +17,11 @@
Eksik örnek üye parametresini ekleyin
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
'new' anahtar sözcüğünü ekleme
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf
index 16a89acc021..e0d31417ab4 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hans.xlf
@@ -17,6 +17,11 @@
添加缺少的实例成员参数
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
添加“新”关键字
diff --git a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf
index 932d4de3e61..89f6de50bcd 100644
--- a/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf
+++ b/vsintegration/src/FSharp.Editor/xlf/FSharp.Editor.zh-Hant.xlf
@@ -17,6 +17,11 @@
新增缺少的執行個體成員參數
+
+ Add missing 'seq'
+ Add missing 'seq'
+
+
Add 'new' keyword
新增 'new' 關鍵字
diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingSeqTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingSeqTests.fs
new file mode 100644
index 00000000000..8a51be6a8fc
--- /dev/null
+++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/AddMissingSeqTests.fs
@@ -0,0 +1,239 @@
+// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
+
+module FSharp.Editor.Tests.CodeFixes.AddMissingSeqTests
+
+open Microsoft.VisualStudio.FSharp.Editor
+open Xunit
+open CodeFixTestFramework
+
+let private codeFix = AddMissingSeqCodeFixProvider()
+
+// This can be changed to Auto when featureDeprecatePlacesWhereSeqCanBeOmitted is out of preview.
+let mode = WithOption "--langversion:preview"
+
+[]
+let ``FS3873 — Adds missing seq before { start..finish }`` () =
+ let code = "let xs = { 1..10 }"
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode = "let xs = seq { 1..10 }"
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS3873 — Adds missing seq before { start..step..finish }`` () =
+ let code = "let xs = { 1..5..10 }"
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode = "let xs = seq { 1..5..10 }"
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS0740 — Adds missing seq before { x; y }`` () =
+ let code = "let xs = { 1; 10 }"
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode = "let xs = seq { 1; 10 }"
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS3873 — Adds missing seq before yield { start..finish }`` () =
+ let code = "let xs = [| yield { 1..100 } |]"
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode = "let xs = [| yield seq { 1..100 } |]"
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS3873 — Adds missing seq before yield { start..finish } multiline`` () =
+ let code =
+ """
+let xs = [| yield seq { 1..100 }
+ yield { 1..100 } |]
+"""
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode =
+ """
+let xs = [| yield seq { 1..100 }
+ yield seq { 1..100 } |]
+"""
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS3873 — Adds parens when needed — app`` () =
+ let code = "let xs = id { 1..10 }"
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode = "let xs = id (seq { 1..10 })"
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS3873 — Adds parens when needed — app parens`` () =
+ let code = "let xs = ResizeArray({ 1..10 })"
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode = "let xs = ResizeArray(seq { 1..10 })"
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS3873 — Adds parens when needed — foreach`` () =
+ let code = "[ for x in { 1..10 } -> x ]"
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode = "[ for x in seq { 1..10 } -> x ]"
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS3873 — Adds parens when needed — dot`` () =
+ let code = "let s = { 1..10 }.ToString ()"
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode = "let s = (seq { 1..10 }).ToString ()"
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS0740 — Adds parens when needed — app`` () =
+ let code = "let xs = id { 1; 10 }"
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode = "let xs = id (seq { 1; 10 })"
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS0740 — Adds parens when needed — dot`` () =
+ let code = "let s = { 1; 10 }.ToString ()"
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode = "let s = (seq { 1; 10 }).ToString ()"
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS3873 — Adds parens when needed — multiline`` () =
+ let code =
+ """
+let xs =
+ id {
+ 1..10
+ }
+"""
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode =
+ """
+let xs =
+ id (seq {
+ 1..10
+ })
+"""
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
+
+[]
+let ``FS0740 — Adds parens when needed — multiline`` () =
+ let code =
+ """
+let xs =
+ id {
+ 1; 10
+ }
+"""
+
+ let expected =
+ Some
+ {
+ Message = "Add missing 'seq'"
+ FixedCode =
+ """
+let xs =
+ id (seq {
+ 1; 10
+ })
+"""
+ }
+
+ let actual = codeFix |> tryFix code mode
+
+ Assert.Equal(expected, actual)
diff --git a/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj b/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj
index a180accc43f..738a3e1323c 100644
--- a/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj
+++ b/vsintegration/tests/FSharp.Editor.Tests/FSharp.Editor.Tests.fsproj
@@ -72,6 +72,7 @@
+