diff options
-rwxr-xr-x | compiler/astalgo.nim | 4 | ||||
-rwxr-xr-x | compiler/semfold.nim | 5 | ||||
-rwxr-xr-x | compiler/semtypinst.nim | 6 | ||||
-rwxr-xr-x | compiler/types.nim | 6 | ||||
-rw-r--r-- | lib/pure/collections/critbits.nim | 2 | ||||
-rwxr-xr-x | lib/pure/osproc.nim | 2 | ||||
-rwxr-xr-x | lib/pure/sockets.nim | 20 | ||||
-rwxr-xr-x | tests/compile/tnewlibs.nim | 2 |
8 files changed, 27 insertions, 20 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index 70cb8653e..a8fc9c8f6 100755 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -391,6 +391,7 @@ proc symToYaml(n: PSym, indent: int = 0, maxRecDepth: int = - 1): PRope = var marker = InitIntSet() result = symToYamlAux(n, marker, indent, maxRecDepth) +proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope proc debugType(n: PType): PRope = if n == nil: result = toRope("null") @@ -407,6 +408,9 @@ proc debugType(n: PType): PRope = app(result, "null") else: app(result, debugType(n.sons[i])) + if n.kind == tyObject and n.n != nil: + app(result, ", node: ") + app(result, debugTree(n.n, 2, 100)) app(result, ")") proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope = diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 9a6665229..eb58a22c6 100755 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -601,7 +601,10 @@ proc getConstExpr(m: PSym, n: PNode): PNode = else: result = magicCall(m, n) of mIs: - result = newIntNodeT(ord(sameType(n[1].typ, n[2].typ)), n) + # BUGFIX: don't evaluate this too early: ``T is void`` + if not containsGenericType(n[1].typ) and + not containsGenericType(n[2].typ): + result = newIntNodeT(ord(sameType(n[1].typ, n[2].typ)), n) of mAstToStr: result = newStrNodeT(renderTree(n[1], {renderNoComments}), n) of mConStrStr: diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index ab7478a54..8cd7c3d1a 100755 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -30,12 +30,6 @@ proc checkConstructedType*(info: TLineInfo, typ: PType) = if t.kind == tyObject and t.sons[0] != nil: if t.sons[0].kind != tyObject or tfFinal in t.sons[0].flags: localError(info, errInheritanceOnlyWithNonFinalObjects) - -proc containsGenericTypeIter(t: PType, closure: PObject): bool = - result = t.kind in GenericTypes - -proc containsGenericType*(t: PType): bool = - result = iterOverType(t, containsGenericTypeIter, nil) proc searchInstTypes(tab: TIdTable, key: PType): PType = # returns nil if we need to declare this type diff --git a/compiler/types.nim b/compiler/types.nim index cbf36b16d..e2200882d 100755 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1094,3 +1094,9 @@ proc getSize(typ: PType): biggestInt = result = computeSize(typ) if result < 0: InternalError("getSize(" & $typ.kind & ')') + +proc containsGenericTypeIter(t: PType, closure: PObject): bool = + result = t.kind in GenericTypes + +proc containsGenericType*(t: PType): bool = + result = iterOverType(t, containsGenericTypeIter, nil) diff --git a/lib/pure/collections/critbits.nim b/lib/pure/collections/critbits.nim index 53033aa6f..40a02b651 100644 --- a/lib/pure/collections/critbits.nim +++ b/lib/pure/collections/critbits.nim @@ -297,6 +297,6 @@ when isMainModule: for w in r.items: echo w - for w in r.allPrefixed("de"): + for w in r.itemsWithPrefix("de"): echo w diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 6ed7e8d2c..b6c18719c 100755 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -455,7 +455,7 @@ when defined(Windows) and not defined(useNimRtl): rfds[i] = readfds[i].FProcessHandle var ret = waitForMultipleObjects(readfds.len.int32, - addr(rfds), 0'i32, timeout) + addr(rfds), 0'i32, timeout.int32) case ret of WAIT_TIMEOUT: return 0 diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim index 162e644d9..af14e7838 100755 --- a/lib/pure/sockets.nim +++ b/lib/pure/sockets.nim @@ -352,7 +352,7 @@ proc bindAddr*(socket: TSocket, port = TPort(0), address = "") = hints.ai_socktype = toInt(SOCK_STREAM) hints.ai_protocol = toInt(IPPROTO_TCP) gaiNim(address, port, hints, aiList) - if bindSocket(socket.fd, aiList.ai_addr, aiList.ai_addrLen) < 0'i32: + if bindSocket(socket.fd, aiList.ai_addr, aiList.ai_addrLen.cint) < 0'i32: OSError() when false: @@ -570,7 +570,7 @@ proc connect*(socket: TSocket, name: string, port = TPort(0), var success = false var it = aiList while it != nil: - if connect(socket.fd, it.ai_addr, it.ai_addrlen) == 0'i32: + if connect(socket.fd, it.ai_addr, it.ai_addrlen.cint) == 0'i32: success = true break it = it.ai_next @@ -624,7 +624,7 @@ proc connectAsync*(socket: TSocket, name: string, port = TPort(0), var success = false var it = aiList while it != nil: - var ret = connect(socket.fd, it.ai_addr, it.ai_addrlen) + var ret = connect(socket.fd, it.ai_addr, it.ai_addrlen.cint) if ret == 0'i32: success = true break @@ -669,8 +669,8 @@ proc connectAsync*(socket: TSocket, name: string, port = TPort(0), proc timeValFromMilliseconds(timeout = 500): TTimeVal = if timeout != -1: var seconds = timeout div 1000 - result.tv_sec = seconds - result.tv_usec = (timeout - seconds * 1000) * 1000 + result.tv_sec = seconds.int32 + result.tv_usec = ((timeout - seconds * 1000) * 1000).int32 #proc recvfrom*(s: TWinSocket, buf: cstring, len, flags: cint, # fromm: ptr TSockAddr, fromlen: ptr cint): cint @@ -772,9 +772,9 @@ proc readIntoBuf(socket: TSocket, flags: int32): int = if socket.isSSL: result = SSLRead(socket.sslHandle, addr(socket.buffer), int(socket.buffer.high)) else: - result = recv(socket.fd, addr(socket.buffer), int(socket.buffer.high), flags) + result = recv(socket.fd, addr(socket.buffer), cint(socket.buffer.high), flags) else: - result = recv(socket.fd, addr(socket.buffer), int(socket.buffer.high), flags) + result = recv(socket.fd, addr(socket.buffer), cint(socket.buffer.high), flags) if result <= 0: socket.buflen = 0 socket.currPos = 0 @@ -824,9 +824,9 @@ proc recv*(socket: TSocket, data: pointer, size: int): int = if socket.isSSL: result = SSLRead(socket.sslHandle, data, size) else: - result = recv(socket.fd, data, size, 0'i32) + result = recv(socket.fd, data, size.cint, 0'i32) else: - result = recv(socket.fd, data, size, 0'i32) + result = recv(socket.fd, data, size.cint, 0'i32) proc waitFor(socket: TSocket, waited: var float, timeout: int): int = ## returns the number of characters available to be read. In unbuffered @@ -1068,7 +1068,7 @@ proc send*(socket: TSocket, data: pointer, size: int): int = return SSLWrite(socket.sslHandle, cast[cstring](data), size) when defined(windows) or defined(macosx): - result = send(socket.fd, data, size, 0'i32) + result = send(socket.fd, data, size.cint, 0'i32) else: result = send(socket.fd, data, size, int32(MSG_NOSIGNAL)) diff --git a/tests/compile/tnewlibs.nim b/tests/compile/tnewlibs.nim index b208b78dd..c742caeaa 100755 --- a/tests/compile/tnewlibs.nim +++ b/tests/compile/tnewlibs.nim @@ -10,7 +10,7 @@ import osproc, cairowin32, cairoxlib, gl, glut, glu, glx, glext, wingl, - lua, lualib, lauxlib, mysql, sqlite3, db_mongo + lua, lualib, lauxlib, mysql, sqlite3, db_mongo, osproc writeln(stdout, "test compilation of binding modules") |