Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete a lot of dead code #11981

Closed
wants to merge 1 commit into from
Closed

Conversation

krux02
Copy link
Contributor

@krux02 krux02 commented Aug 19, 2019

This PR is ruthless, when some code is deactivated with when false, I deleted it. One reason this PR is here is to show how much dead code has been accumulated over the years. I think at some point one should just dump it all.

else:
genAssignment(p, d, tmpB, {})
else:
when true:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: you could do the same as in https://github.com/nim-lang/Nim/pull/11981/files#diff-c771980a90bdbd4401f414dee2b14915R32 — without when true, just unindent its block. I think it is a cleaner solution.

Copy link
Contributor Author

@krux02 krux02 Aug 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I can. I decided against it because in such a big PR I wanted to focus on trivial code changes. In the code you reference I wasn't so strict yet.

@juancarlospaco
Copy link
Collaborator

Awesome work. 🙂 👍

@@ -1455,14 +1455,6 @@ proc parseExprStmt(p: var TParser): PNode =

proc parseModuleName(p: var TParser, kind: TNodeKind): PNode =
result = parseExpr(p)
when false:
# parseExpr already handles 'as' syntax ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe keep the comment # parseExpr already handles 'as' syntax ...

@@ -150,15 +149,6 @@ proc commonType*(x, y: PType): PType =
# run people expect ranges to work properly within a tuple.
if not sameType(a, b):
result = skipTypes(a, {tyRange}).skipIntLit
when false:
if a.kind != tyRange and b.kind == tyRange:
# XXX This really needs a better solution, but a proper fix now breaks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe at least summarize this deleted block with a comment

@@ -365,18 +365,6 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
# branches will be reported as an error):
let initResult = semConstructType(c, result, t, flags)

# It's possible that the object was not fully initialized while
Copy link
Member

@timotheecour timotheecour Aug 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this definitely should show at least a summarizing comment; might as well keep this block IMO as it's still in TODO state

@@ -480,21 +480,12 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
($typ.kind).substr(2).toLowerAscii)
elif typ.kind == tyProc and tfUnresolved in typ.flags:
localError(c.config, def.info, errProcHasNoConcreteType % def.renderTree)
when false:
# XXX This typing rule is neither documented nor complete enough to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least some comment should stay

@@ -133,14 +133,6 @@ proc initCandidate*(ctx: PContext, c: var TCandidate, callee: PType) =
initIdTable(c.bindings)

proc put(c: var TCandidate, key, val: PType) {.inline.} =
when false:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful to keep for debugging (I've actually used it) ; maybe add a comment instead of deleting:

when false: # debugging
   ...

@@ -2506,9 +2451,6 @@ proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) =
m.call = n
# Note the following doesn't work as it would produce ambiguities.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment now makes no sense after the code is deleted; maybe enhance the comment instead

@@ -935,11 +911,6 @@ proc transform(c: PTransf, n: PNode): PTransNode =
result = PTransNode(n)
of nkMacroDef:
# XXX no proper closure support yet:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment now makes no sense; maybe keep dead code (as a WIP)

@@ -477,10 +459,6 @@ proc runCI(cmd: string) =
## build nimble early on to enable remainder to depend on it if needed
kochExecFold("Build Nimble", "nimble")

when false:
Copy link
Member

@timotheecour timotheecour Aug 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep this and maybe add a comment # consider re-enabling or similar; original PR #10150 showed when not defined(windows): and then was turned into when false in c5dbb03 ; as a result compile time FFI is not being tested in testament anymore and (unsurprisingly) it started to bitrot, cf my PR from yesterday #11991
CTFFI is a super powerful feature that I heavily rely on; it needs more eyes on it, not less

@@ -87,11 +87,3 @@ proc newImpl(t: ptr TypeLayout): pointer =

template new*[T](x: var ref T) =
x = newImpl(getTypeLayout(x))


when false:
Copy link
Member

@timotheecour timotheecour Aug 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this block, this is a reference

@@ -294,8 +294,6 @@ iterator fields*(x: Any): tuple[name: string, any: Any] =
var p = x.value
var t = x.rawType
# XXX BUG: does not work yet, however is questionable anyway
Copy link
Member

@timotheecour timotheecour Aug 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment makes no sense after deletion; either keep that block (might as well) or enhance comment; likewise with other instances in this file

@@ -812,58 +812,6 @@ proc acceptAddr*(server: Socket, client: var owned(Socket), address: var string,
let ret = SSLAccept(client.sslHandle)
socketError(client, ret, false)

when false: #defineSsl:
proc acceptAddrSSL*(server: Socket, client: var Socket,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @dom96 since you moved that code here in 2ce9f1c

@@ -410,15 +410,6 @@ proc pageAddr(p: pointer): PChunk {.inline.} =
result = cast[PChunk](cast[ByteAddress](p) and not PageMask)
#sysAssert(Contains(allocator.chunkStarts, pageIndex(result)))

when false:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe keep with a comment when false: # debugging ?

@@ -1009,14 +901,6 @@ template instantiateForRegion(allocator: untyped) =
proc realloc(p: pointer, newsize: Natural): pointer =
result = realloc(allocator, p, newsize)

when false:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this (used in commented out #sysAssert(result == countFreeMem()))
or if you do remove it, you'd need to also remove #sysAssert(result == countFreeMem())

@@ -142,11 +142,6 @@ proc genericDeepCopyAux(dest, src: pointer, mt: PNimType; tab: var PtrTable) =
tab.put(s2, z)
genericDeepCopyAux(z, s2, realType.base, tab)
else:
when false:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this; I think I've used this during a debugging session

@@ -451,13 +446,6 @@ proc GC_dumpHeap*(file: File) =
## can be translated into "dot" syntax via the "heapdump2dot" tool.
gch.pDumpHeapFile = file
var spaceIter: ObjectSpaceIter
when false:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems useful (and non-trivial) for debugging

@@ -23,8 +23,6 @@ Base.pr
Child.pr

Base.me
when false:
Child.me #<- bug #2710
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disabled code for documentation purposes => I'd keep it

@@ -63,17 +63,6 @@ proc asyncTest() {.async.} =
except:
doAssert(false, "HttpRequestError should have been raised")


when false:
# w3.org now blocks travis, so disabled:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems useful code that can be run locally to test functionality

@@ -71,9 +71,6 @@ block:
block:
static:
# for joint test, the project path is different, so I disabled it:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment makes no sense after deletion

Copy link
Member

@timotheecour timotheecour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for this; I went through everything; a small fraction should stay or require some minor changes, see comments

@Araq
Copy link
Member

Araq commented Aug 22, 2019

I won't merge this, in plenty of places the when false contains valuable source code, comments and information. And I don't want to review it again. I also don't want you to spend more time on this.

@Araq Araq closed this Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants