From b2141fc2a12b239c4b24f38ffbd3ca629278630e Mon Sep 17 00:00:00 2001 From: hlaaftana <10591326+hlaaftana@users.noreply.github.com> Date: Fri, 24 Apr 2020 10:22:12 +0300 Subject: [PATCH] changed type() to typeof() in docs and error messages (#14084) --- compiler/semcall.nim | 2 +- compiler/types.nim | 2 +- doc/destructors.rst | 4 ++-- doc/manual.rst | 2 +- doc/manual_experimental.rst | 4 ++-- doc/tut2.rst | 2 +- lib/js/jsffi.nim | 2 +- lib/pure/typetraits.nim | 2 +- lib/system/dollars.nim | 6 +++--- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 321745c82b..ab28c21b23 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -633,7 +633,7 @@ proc explicitGenericInstantiation(c: PContext, n: PNode, s: PSym): PNode = if s.ast[genericParamsPos].safeLen != n.len-1: let expected = s.ast[genericParamsPos].safeLen localError(c.config, getCallLineInfo(n), errGenerated, "cannot instantiate: '" & renderTree(n) & - "'; got " & $(n.len-1) & " type(s) but expected " & $expected) + "'; got " & $(n.len-1) & " typeof(s) but expected " & $expected) return n result = explicitGenericSym(c, n, s) if result == nil: result = explicitGenericInstError(c, n) diff --git a/compiler/types.nim b/compiler/types.nim index eac9695b63..b75a97c259 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -587,7 +587,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = if t.n == nil: result = "unknown" else: - result = "type(" & renderTree(t.n) & ")" + result = "typeof(" & renderTree(t.n) & ")" of tyArray: if t[0].kind == tyRange: result = "array[" & rangeToStr(t[0].n) & ", " & diff --git a/doc/destructors.rst b/doc/destructors.rst index 0d4a6c9855..2b1222778a 100644 --- a/doc/destructors.rst +++ b/doc/destructors.rst @@ -48,7 +48,7 @@ written as: a.len = b.len a.cap = b.cap if b.data != nil: - a.data = cast[type(a.data)](alloc(a.cap * sizeof(T))) + a.data = cast[typeof(a.data)](alloc(a.cap * sizeof(T))) for i in 0.. 97 The type conversion ``T(a)`` is an L-value if ``a`` is an L-value and -``typeEqualsOrDistinct(T, type(a))`` holds. +``typeEqualsOrDistinct(T, typeof(a))`` holds. Assignment compatibility diff --git a/doc/manual_experimental.rst b/doc/manual_experimental.rst index f65c0933b7..70bb225fa1 100644 --- a/doc/manual_experimental.rst +++ b/doc/manual_experimental.rst @@ -619,7 +619,7 @@ type is an instance of it: type Functor[A] = concept f - type MatchedGenericType = genericHead(f.type) + type MatchedGenericType = genericHead(typeof(f)) # `f` will be a value of a type such as `Option[T]` # `MatchedGenericType` will become the `Option` type @@ -652,7 +652,7 @@ matched to a concrete type: t1 < t2 is bool - type TimeSpan = type(t1 - t2) + type TimeSpan = typeof(t1 - t2) TimeSpan * int is TimeSpan TimeSpan + TimeSpan is TimeSpan diff --git a/doc/tut2.rst b/doc/tut2.rst index 419e06930d..0338bdb1ad 100644 --- a/doc/tut2.rst +++ b/doc/tut2.rst @@ -651,7 +651,7 @@ Example: Lifting Procs ## # now abs(@[@[1,-2], @[-2,-3]]) == @[@[1,2], @[2,3]] proc fname[T](x: openarray[T]): auto = var temp: T - type outType = type(fname(temp)) + type outType = typeof(fname(temp)) result = newSeq[outType](x.len) for i in 0..`_. ## ## .. code-block:: Nim - ## doAssert $(type(42)) == "int" - ## doAssert $(type("Foo")) == "string" - ## static: doAssert $(type(@['A', 'B'])) == "seq[char]" + ## doAssert $(typeof(42)) == "int" + ## doAssert $(typeof("Foo")) == "string" + ## static: doAssert $(typeof(@['A', 'B'])) == "seq[char]" when defined(nimHasIsNamedTuple): proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".}