From 76763f51aa119e71b00200142292acf5f1fdc69c Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 21 Oct 2022 06:55:52 +0200 Subject: [PATCH] implemented strictCaseObjects (#20608) * implemented strictCaseObjects * changelog update --- changelog.md | 8 ++++-- compiler/guards.nim | 8 ++++-- compiler/options.nim | 3 ++- compiler/sempass2.nim | 6 ++--- doc/manual_experimental.md | 36 +++++++++++++++++++++++++++ tests/effects/tstrict_caseobjects.nim | 27 ++++++++++++++++++++ 6 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 tests/effects/tstrict_caseobjects.nim diff --git a/changelog.md b/changelog.md index 0bcedb7179..1cb2328ba4 100644 --- a/changelog.md +++ b/changelog.md @@ -1,8 +1,8 @@ -# v1.8.x - yyyy-mm-dd +# v2.0.0 - yyyy-mm-dd ## Changes affecting backward compatibility -- `httpclient.contentLength` default to `-1` if the Content-Length header is not set in the response, it followed Apache HttpClient(Java), http(go) and .Net HttpWebResponse(C#) behavior. Previously raise `ValueError`. +- `httpclient.contentLength` default to `-1` if the Content-Length header is not set in the response, it followed Apache HttpClient(Java), http(go) and .Net HttpWebResponse(C#) behavior. Previously it raised `ValueError`. - `addr` is now available for all addressable locations, `unsafeAddr` is now deprecated and an alias for `addr`. @@ -216,6 +216,10 @@ need to convert to `string`. On the JS backend, this is translated directly to a `switch` statement. +- Nim now supports `out` parameters and ["strict definitions"](https://nim-lang.github.io/Nim/manual_experimental.html#strict-definitions-and-nimout-parameters). +- Nim now offers a [strict mode](https://nim-lang.github.io/Nim/manual_experimental.html#strict-case-objects) for `case objects`. + + ## Compiler changes - The `gc` switch has been renamed to `mm` ("memory management") in order to reflect the diff --git a/compiler/guards.nim b/compiler/guards.nim index f14c1d9155..33bf3d99c3 100644 --- a/compiler/guards.nim +++ b/compiler/guards.nim @@ -1054,8 +1054,12 @@ proc buildProperFieldCheck(access, check: PNode; o: Operators): PNode = assert check.getMagic == mNot result = buildProperFieldCheck(access, check[1], o).neg(o) -proc checkFieldAccess*(m: TModel, n: PNode; conf: ConfigRef) = +proc checkFieldAccess*(m: TModel, n: PNode; conf: ConfigRef; produceError: bool) = for i in 1..