Merge branch 'devel' into new-ll

This commit is contained in:
Andreas Rumpf
2015-12-29 20:45:22 +01:00
9 changed files with 35 additions and 23 deletions

View File

@@ -19,10 +19,7 @@ proc genConv(n: PNode, d: PType, downcast: bool): PNode =
if (source.kind == tyObject) and (dest.kind == tyObject):
var diff = inheritanceDiff(dest, source)
if diff == high(int):
# see bug #3550 which triggers it. XXX This is a hack but I don't know yet
# how the real fix looks like:
localError(n.info, "there is no subtype relation between " &
typeToString(d) & " and " & typeToString(n.typ))
# no subtype relation, nothing to do
result = n
elif diff < 0:
result = newNodeIT(nkObjUpConv, n.info, d)

View File

@@ -40,6 +40,8 @@
##
## theDb.close()
{.deadCodeElim:on.}
import strutils, sqlite3
import db_common

View File

@@ -110,7 +110,7 @@ type
EInvalidProtocol: ProtocolError, EHttpRequestErr: HttpRequestError
].}
const defUserAgent* = "Nim httpclient/0.1"
const defUserAgent* = "Nim httpclient/" & NimVersion
proc httpError(msg: string) =
var e: ref ProtocolError
@@ -389,6 +389,7 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
## | An optional timeout can be specified in milliseconds, if reading from the
## server takes longer than specified an ETimeout exception will be raised.
var r = if proxy == nil: parseUri(url) else: proxy.url
var hostUrl = if proxy == nil: r else: parseUri(url)
var headers = substr(httpMethod, len("http"))
# TODO: Use generateHeaders further down once it supports proxies.
if proxy == nil:
@@ -402,10 +403,10 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
headers.add(" HTTP/1.1\c\L")
if r.port == "":
add(headers, "Host: " & r.hostname & "\c\L")
if hostUrl.port == "":
add(headers, "Host: " & hostUrl.hostname & "\c\L")
else:
add(headers, "Host: " & r.hostname & ":" & r.port & "\c\L")
add(headers, "Host: " & hostUrl.hostname & ":" & hostUrl.port & "\c\L")
if userAgent != "":
add(headers, "User-Agent: " & userAgent & "\c\L")
@@ -414,7 +415,6 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
add(headers, "Proxy-Authorization: basic " & auth & "\c\L")
add(headers, extraHeaders)
add(headers, "\c\L")
var s = newSocket()
if s == nil: raiseOSError(osLastError())
var port = net.Port(80)

View File

@@ -206,7 +206,7 @@ proc getAddrInfo*(address: string, port: Port, domain: Domain = AF_INET,
# OpenBSD doesn't support AI_V4MAPPED and doesn't define the macro AI_V4MAPPED.
# FreeBSD doesn't support AI_V4MAPPED but defines the macro.
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198092
when not defined(freebsd) or defined(openbsd):
when not defined(freebsd) and not defined(openbsd) and not defined(netbsd):
if domain == AF_INET6:
hints.ai_flags = AI_V4MAPPED
var gaiResult = getaddrinfo(address, $port, addr(hints), result)

View File

@@ -886,7 +886,7 @@ elif not defined(useNimRtl):
discard write(data.pErrorPipe[writeIdx], addr error, sizeof(error))
exitnow(1)
when defined(macosx) or defined(freebsd):
when defined(macosx) or defined(freebsd) or defined(netbsd):
var environ {.importc.}: cstringArray
proc startProcessAfterFork(data: ptr StartProcessData) =
@@ -916,7 +916,7 @@ elif not defined(useNimRtl):
discard fcntl(data.pErrorPipe[writeIdx], F_SETFD, FD_CLOEXEC)
if data.optionPoUsePath:
when defined(macosx) or defined(freebsd):
when defined(macosx) or defined(freebsd) or defined(netbsd):
# MacOSX doesn't have execvpe, so we need workaround.
# On MacOSX we can arrive here only from fork, so this is safe:
environ = data.sysEnv

View File

@@ -68,9 +68,10 @@ when defined(posix):
proc nimLoadLibrary(path: string): LibHandle =
result = dlopen(path, RTLD_NOW)
let error = dlerror()
if error != nil:
c_fprintf(c_stdout, "%s\n", error)
when defined(nimDebugDlOpen):
let error = dlerror()
if error != nil:
c_fprintf(c_stdout, "%s\n", error)
proc nimGetProcAddr(lib: LibHandle, name: cstring): ProcAddr =
result = dlsym(lib, name)

View File

@@ -242,7 +242,7 @@ template task*(name: untyped; description: string; body: untyped): untyped =
## .. code-block:: nim
## task build, "default build is via the C backend":
## setCommand "c"
proc `name Task`() = body
proc `name Task`*() = body
let cmd = getCommand()
if cmd.len == 0 or cmd ==? "help":

View File

@@ -1,7 +0,0 @@
discard """
file: "tissue1642.nim"
disabled: true
"""
block:
var i = 0
proc p() = inc(i)

19
tests/method/tmultim8.nim Normal file
View File

@@ -0,0 +1,19 @@
# bug #3550
type
BaseClass = ref object of RootObj
Class1 = ref object of BaseClass
Class2 = ref object of BaseClass
method test(obj: Class1, obj2: BaseClass) =
discard
method test(obj: Class2, obj2: BaseClass) =
discard
var obj1 = Class1()
var obj2 = Class2()
obj1.test(obj2)
obj2.test(obj1)