From 0c56eeda0e3a9a2fd5bb3d9b53f593d6d41fb5d9 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Thu, 25 Jun 2020 01:22:08 -0700 Subject: [PATCH] expr => untyped; stmt => typed (#14804) * expr => untyped; stmt => typed * changelog + comment --- changelog.md | 1 + compiler/vmdeps.nim | 4 ++-- tests/metatype/ttypetraits.nim | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 2c7cdeed09..07d9b61126 100644 --- a/changelog.md +++ b/changelog.md @@ -221,6 +221,7 @@ proc mydiv(a, b): int {.raises: [].} = See [docgen](docgen.html#introduction-quick-start) for details. - Removed the `--oldNewlines` switch. - Removed the `--laxStrings` switch for mutating the internal zero terminator on strings. +- `$getType(untyped)` is now "untyped" instead of "expr", `$getType(typed)` is now "typed" instead of "stmt" ## Tool changes diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index 6f90b79189..4ba7b23bf8 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -93,8 +93,8 @@ proc mapTypeToAstX(cache: IdentCache; t: PType; info: TLineInfo; of tyBool: result = atomicType("bool", mBool) of tyChar: result = atomicType("char", mChar) of tyNil: result = atomicType("nil", mNil) - of tyUntyped: result = atomicType("expr", mExpr) - of tyTyped: result = atomicType("stmt", mStmt) + of tyUntyped: result = atomicType("untyped", mExpr) + of tyTyped: result = atomicType("typed", mStmt) of tyVoid: result = atomicType("void", mVoid) of tyEmpty: result = atomicType("empty", mNone) of tyUncheckedArray: diff --git a/tests/metatype/ttypetraits.nim b/tests/metatype/ttypetraits.nim index 10aa7783d4..d0480415e1 100644 --- a/tests/metatype/ttypetraits.nim +++ b/tests/metatype/ttypetraits.nim @@ -49,6 +49,12 @@ block: # typeToString doAssert (tuple[a: C2b[MyInt, C4[cstring]], b: cint, c: float]).name3 == "tuple[a: C[MyInt{int}, C4[cstring]], b: cint{int32}, c: float]" + macro fn(): string = + # not 100% sure whether this should even compile; if some PR breaks this test, + # this could be revisited, maybe. + newLit $($getType(untyped), $getType(typed)) + doAssert fn() == """("untyped", "typed")""" + block distinctBase: block: type