concept example from the manual now works again
This commit is contained in:
parent
f6ff01572e
commit
3bcafb1c3a
5 changed files with 18 additions and 32 deletions
|
|
@ -587,22 +587,15 @@ proc unknownLineInfo*(): TLineInfo =
|
||||||
var
|
var
|
||||||
msgContext: seq[TLineInfo] = @[]
|
msgContext: seq[TLineInfo] = @[]
|
||||||
lastError = unknownLineInfo()
|
lastError = unknownLineInfo()
|
||||||
bufferedMsgs*: seq[string]
|
|
||||||
|
|
||||||
errorOutputs* = {eStdOut, eStdErr}
|
errorOutputs* = {eStdOut, eStdErr}
|
||||||
writelnHook*: proc (output: string) {.closure.}
|
writelnHook*: proc (output: string) {.closure.}
|
||||||
|
|
||||||
proc clearBufferedMsgs* =
|
|
||||||
bufferedMsgs = nil
|
|
||||||
|
|
||||||
proc suggestWriteln*(s: string) =
|
proc suggestWriteln*(s: string) =
|
||||||
if eStdOut in errorOutputs:
|
if eStdOut in errorOutputs:
|
||||||
if isNil(writelnHook): writeln(stdout, s)
|
if isNil(writelnHook): writeln(stdout, s)
|
||||||
else: writelnHook(s)
|
else: writelnHook(s)
|
||||||
|
|
||||||
if eInMemory in errorOutputs:
|
|
||||||
bufferedMsgs.safeAdd(s)
|
|
||||||
|
|
||||||
proc msgQuit*(x: int8) = quit x
|
proc msgQuit*(x: int8) = quit x
|
||||||
proc msgQuit*(x: string) = quit x
|
proc msgQuit*(x: string) = quit x
|
||||||
|
|
||||||
|
|
@ -705,8 +698,6 @@ proc msgWriteln*(s: string) =
|
||||||
else:
|
else:
|
||||||
if eStdOut in errorOutputs: writeln(stdout, s)
|
if eStdOut in errorOutputs: writeln(stdout, s)
|
||||||
|
|
||||||
if eInMemory in errorOutputs: bufferedMsgs.safeAdd(s)
|
|
||||||
|
|
||||||
proc coordToStr(coord: int): string =
|
proc coordToStr(coord: int): string =
|
||||||
if coord == -1: result = "???"
|
if coord == -1: result = "???"
|
||||||
else: result = $coord
|
else: result = $coord
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,11 @@
|
||||||
# included from sem.nim
|
# included from sem.nim
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TTypeAttachedOp = enum
|
||||||
|
attachedDestructor,
|
||||||
|
attachedAsgn,
|
||||||
|
attachedDeepCopy
|
||||||
|
|
||||||
TLiftCtx = object
|
TLiftCtx = object
|
||||||
c: PContext
|
c: PContext
|
||||||
info: TLineInfo # for construction
|
info: TLineInfo # for construction
|
||||||
|
|
@ -195,3 +200,4 @@ proc liftBody(c: PContext; typ: PType; info: TLineInfo): PNode =
|
||||||
a.info = info
|
a.info = info
|
||||||
a.result = newNodeI(nkStmtList, info)
|
a.result = newNodeI(nkStmtList, info)
|
||||||
liftBodyAux(a, typ)
|
liftBodyAux(a, typ)
|
||||||
|
result = a.result
|
||||||
|
|
|
||||||
|
|
@ -499,6 +499,7 @@ proc matchUserTypeClass*(c: PContext, m: var TCandidate,
|
||||||
param.typ = makeTypeDesc(c, typ)
|
param.typ = makeTypeDesc(c, typ)
|
||||||
|
|
||||||
addDecl(c, param)
|
addDecl(c, param)
|
||||||
|
#echo "A ", param.name.s, " ", typeToString(param.typ), " ", param.kind
|
||||||
|
|
||||||
for param in body.n[0]:
|
for param in body.n[0]:
|
||||||
var
|
var
|
||||||
|
|
@ -507,30 +508,19 @@ proc matchUserTypeClass*(c: PContext, m: var TCandidate,
|
||||||
|
|
||||||
if param.kind == nkVarTy:
|
if param.kind == nkVarTy:
|
||||||
dummyName = param[0]
|
dummyName = param[0]
|
||||||
dummyType = if a.kind != tyVar: makeVarType(c, a)
|
dummyType = if a.kind != tyVar: makeVarType(c, a) else: a
|
||||||
else: a
|
|
||||||
else:
|
else:
|
||||||
dummyName = param
|
dummyName = param
|
||||||
dummyType = a
|
dummyType = a
|
||||||
|
|
||||||
internalAssert dummyName.kind == nkIdent
|
internalAssert dummyName.kind == nkIdent
|
||||||
var dummyParam = newSym(skType, dummyName.ident, body.sym, body.sym.info)
|
var dummyParam = newSym(skVar, dummyName.ident, body.sym, body.sym.info)
|
||||||
dummyParam.typ = dummyType
|
dummyParam.typ = dummyType
|
||||||
addDecl(c, dummyParam)
|
addDecl(c, dummyParam)
|
||||||
|
#echo "B ", dummyName.ident.s, " ", typeToString(dummyType), " ", dummyparam.kind
|
||||||
|
|
||||||
var checkedBody = c.semTryExpr(c, body.n[3].copyTree)
|
var checkedBody = c.semTryExpr(c, body.n[3].copyTree)
|
||||||
#m.errors = bufferedMsgs
|
|
||||||
clearBufferedMsgs()
|
|
||||||
if checkedBody == nil: return isNone
|
if checkedBody == nil: return isNone
|
||||||
|
|
||||||
if checkedBody.kind == nkStmtList:
|
|
||||||
for stmt in checkedBody:
|
|
||||||
case stmt.kind
|
|
||||||
of nkReturnStmt: discard
|
|
||||||
of nkTypeSection: discard
|
|
||||||
of nkConstDef: discard
|
|
||||||
else: discard
|
|
||||||
|
|
||||||
return isGeneric
|
return isGeneric
|
||||||
|
|
||||||
proc shouldSkipDistinct(rules: PNode, callIdent: PIdent): bool =
|
proc shouldSkipDistinct(rules: PNode, callIdent: PIdent): bool =
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ e
|
||||||
s
|
s
|
||||||
t
|
t
|
||||||
'''
|
'''
|
||||||
disabled: "true"
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
template accept(e: expr) =
|
template accept(e: expr) =
|
||||||
|
|
@ -22,10 +21,10 @@ template reject(e: expr) =
|
||||||
static: assert(not compiles(e))
|
static: assert(not compiles(e))
|
||||||
|
|
||||||
type
|
type
|
||||||
Container[T] = concept C
|
Container[T] = concept c
|
||||||
C.len is Ordinal
|
c.len is Ordinal
|
||||||
items(c) is iterator
|
items(c) is iterator
|
||||||
for value in C:
|
for value in c:
|
||||||
type(value) is T
|
type(value) is T
|
||||||
|
|
||||||
proc takesIntContainer(c: Container[int]) =
|
proc takesIntContainer(c: Container[int]) =
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -6,12 +6,12 @@ version 0.10.4
|
||||||
- make 'nil' work for 'add' and 'len'
|
- make 'nil' work for 'add' and 'len'
|
||||||
- add "all threads are blocked" detection to 'spawn'
|
- add "all threads are blocked" detection to 'spawn'
|
||||||
- overloading of '='
|
- overloading of '='
|
||||||
|
- disallow negative indexing
|
||||||
|
|
||||||
|
|
||||||
version 1.0
|
version 1.0
|
||||||
===========
|
===========
|
||||||
|
|
||||||
- disallow negative indexing
|
|
||||||
- figure out why C++ bootstrapping is so much slower
|
- figure out why C++ bootstrapping is so much slower
|
||||||
- nimsuggest: auto-completion needs to work in 'class' macros
|
- nimsuggest: auto-completion needs to work in 'class' macros
|
||||||
- improve the docs for inheritance
|
- improve the docs for inheritance
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue