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