mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 12:37:46 +00:00
bugfix: 'not nil' and 'shared' types
This commit is contained in:
@@ -787,6 +787,12 @@ proc semTypeExpr(c: PContext, n: PNode): PType =
|
||||
else:
|
||||
LocalError(n.info, errTypeExpected, n.renderTree)
|
||||
|
||||
proc freshType(res, prev: PType): PType {.inline.} =
|
||||
if prev.isNil:
|
||||
result = copyType(result, result.owner, keepId=false)
|
||||
else:
|
||||
result = res
|
||||
|
||||
proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||
result = nil
|
||||
if gCmd == cmdIdeTools: suggestExpr(c, n)
|
||||
@@ -825,7 +831,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||
checkSonsLen(n, 3)
|
||||
result = semTypeNode(c, n.sons[1], prev)
|
||||
if result.kind in NilableTypes and n.sons[2].kind == nkNilLit:
|
||||
# XXX this is wrong for tyString at least
|
||||
result = freshType(result, prev)
|
||||
result.flags.incl(tfNotNil)
|
||||
else:
|
||||
LocalError(n.info, errGenerated, "invalid type")
|
||||
@@ -920,6 +926,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||
of nkSharedTy:
|
||||
checkSonsLen(n, 1)
|
||||
result = semTypeNode(c, n.sons[0], prev)
|
||||
result = freshType(result, prev)
|
||||
result.flags.incl(tfShared)
|
||||
else:
|
||||
LocalError(n.info, errTypeExpected)
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
## For OpenSSL support compile with ``-d:ssl``. When using SSL be aware that
|
||||
## most functions will then raise ``ESSL`` on SSL errors.
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
when hostos == "solaris":
|
||||
{.passl: "-lsocket -lnsl".}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
|
||||
## OpenSSL support
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
when defined(WINDOWS):
|
||||
const
|
||||
DLLSSLName = "(ssleay32|libssl32).dll"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
discard """
|
||||
line: 11
|
||||
line: 22
|
||||
errormgs: "type mismatch"
|
||||
"""
|
||||
|
||||
@@ -7,9 +7,17 @@ type
|
||||
PObj = ref TObj not nil
|
||||
TObj = object
|
||||
x: int
|
||||
|
||||
MyString = string not nil
|
||||
|
||||
var x: PObj = nil
|
||||
#var x: PObj = nil
|
||||
|
||||
proc p(x: string not nil): int =
|
||||
result = 45
|
||||
|
||||
proc q(x: MyString) = nil
|
||||
proc q2(x: string) = nil
|
||||
|
||||
q2(nil)
|
||||
q(nil)
|
||||
|
||||
|
||||
3
todo.txt
3
todo.txt
@@ -1,7 +1,6 @@
|
||||
version 0.9.2
|
||||
=============
|
||||
|
||||
- fix tfShared and tfNotNil
|
||||
- test&finish first class iterators:
|
||||
* nested iterators
|
||||
* test generic iterators
|
||||
@@ -20,7 +19,7 @@ version 0.9.X
|
||||
=============
|
||||
|
||||
- implement the missing features wrt inheritance
|
||||
- implement generic methods
|
||||
- implement generic methods and generic converters
|
||||
- improve the compiler as a service
|
||||
- ``=`` should be overloadable; requires specialization for ``=``
|
||||
- implement constructors + full 'not nil' checking
|
||||
|
||||
Reference in New Issue
Block a user