Skip to content

Commit

Permalink
add regression test; clarify some dosc
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Sep 3, 2021
1 parent feb3094 commit 5df62a3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions compiler/lookups.nim
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ type
checkAmbiguity, checkUndeclared, checkModule, checkPureEnumFields

proc qualifiedLookUp*(c: PContext, n: PNode, flags: set[TLookupFlag]): PSym =
# `determineType2` should not be called inside this; instead callers should selectively call it as needed.
const allExceptModule = {low(TSymKind)..high(TSymKind)} - {skModule, skPackage}
case n.kind
of nkIdent, nkAccQuoted:
Expand Down
6 changes: 3 additions & 3 deletions compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ proc semSym(c: PContext, n: PNode, sym: PSym, flags: TExprFlags): PNode =
#if efInCall notin flags:
markUsed(c, info, s)
onUse(info, s)
determineType2(c, s) # PRTEMP
determineType2(c, s) # needed, e.g. for semchecking `proc f(a = fn)`; xxx see whether other branches also need this
result = newSymNode(s, info)

proc tryReadingGenericParam(c: PContext, n: PNode, i: PIdent, t: PType): PNode =
Expand Down Expand Up @@ -2758,7 +2758,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
else:
{checkUndeclared, checkModule, checkAmbiguity, checkPureEnumFields}
var s = qualifiedLookUp(c, n, checks)
determineType2(c, s) # PRTEMP: inside qualifiedLookUp instead? already case?
determineType2(c, s) # needed
if c.matchedConcept == nil: semCaptureSym(s, c.p.owner)
case s.kind
of skProc, skFunc, skMethod, skConverter, skIterator:
Expand Down Expand Up @@ -2847,7 +2847,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
c.isAmbiguous = false
var s = qualifiedLookUp(c, n[0], mode)
if s != nil:
determineType2(c, s) # PRTEMP: inside qualifiedLookUp ? already case?
determineType2(c, s) # needed, see D20210902T181022
#if c.config.cmd == cmdNimfix and n[0].kind == nkDotExpr:
# pretty.checkUse(n[0][1].info, s)
case s.kind
Expand Down
10 changes: 9 additions & 1 deletion tests/misc/mlazysemcheck.nim
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ elif defined case_stdlib:
let t2 = now()
doAssert t2 > t

elif defined case_test2:
import std/macros
block: # regression test D20210902T181022:here
macro foo(normalizer: static[proc(s :string): string]): untyped =
let ret = quote: `normalizer`
proc baz(s: string): string = discard
foo(baz)

elif defined case_stdlib_imports:
#[
from tests/test_nimscript.nims, minus 1 module, see below
Expand Down Expand Up @@ -510,7 +518,7 @@ elif defined case_stdlib_imports:

elif defined case_perf:
#[
TODO:
PRTEMP TODO:
example showing perf for lots of imports
]#
import std/[strutils, os, times, enumutils, browsers]
Expand Down
2 changes: 1 addition & 1 deletion tests/misc/tlazysemcheck.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ proc check(opt: string, expected: string) =
doAssert expected in actual, fmt("{opt=}\n{actual=}\n{expected=}")

proc main =
for opt in "-d:case_noimports; -d:case_reordering; -d:case_stdlib ; -d:case_stdlib_imports; -d:case_import1; -d:case_cyclic; -d:case_perf".split(";"):
for opt in "-d:case_noimports; -d:case_reordering; -d:case_stdlib ; -d:case_stdlib_imports; -d:case_import1; -d:case_cyclic; -d:case_test2; -d:case_perf".split(";"):
check(opt): "" # we can add per-test expectations on compiler output here, e.g. to ensure certain APIs were (or not) compiled
main()

0 comments on commit 5df62a3

Please sign in to comment.