timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

misc issues #6

Open timotheecour opened 5 years ago

timotheecour commented 5 years ago
timotheecour commented 5 years ago
timotheecour commented 5 years ago

-d:release:off doesn't unset -d:release ; WORKAROUND: use -u:release

timotheecour commented 4 years ago

EDIT: fixed in https://github.com/nim-lang/Nim/pull/13642 (via checkDir option)

timotheecour commented 4 years ago
proc toDll*(filename: string): string =
  ## On Windows adds ".dll" to `filename`, on Posix produces "lib$filename.so".
  (when defined(windows): filename & ".dll" else: "lib" & filename & ".so")

=> OSX??

timotheecour commented 4 years ago

Edited: Itt works now nim e --eval:"try: echo 1 except Exception as e: echo 2" prints: 1

timotheecour commented 4 years ago

adding --passc:-flto does not recompile C sources; need -f workaround

timotheecour commented 4 years ago
timotheecour commented 4 years ago
timotheecour commented 4 years ago

line tracing doesn't help here:

--embedsrc
--linetrace:on
--linedir
nimb cpp -r -f -d:case1 --stacktrace:on --passc:-D=NIM_ENABLE_BACKEND_WARNING --passC:'-Wwrite-strings -Wno-tautological-constant-out-of-range-compare -Wno-incompatible-pointer-types-discards-qualifiers -Wno-writable-strings -Wno-invalid-offsetof' --embedsrc --hint:cc:on --linetrace:on --linedir compiler/btrees.nim
#line 159 "/Users/timothee/git_clone/nim/Nim_prs/compiler/btrees.nim"
    unsureAsgnRef((void**) (&(*Result).Field0), copyString(colontmp_)); unsureAsgnRef((void**) (&(*Result).Field1), copyString(colontmp__2));   (*Result).Field2 = colontmp__3; popFrame();}
static N_NIMCALL(void, Marker_tyRef__IL7aN7O9aNru9bTSC89c5Ikqw)(void* p, NI op) {
    tyObject_NodecolonObjectType___N9cnVBw3Vb4RjTWgNwB6wqw* a;
    NI T1_; NI T2_; NI T3_; a = (tyObject_NodecolonObjectType___N9cnVBw3Vb4RjTWgNwB6wqw*)p;
    T1_ = (NI)0;    switch ((*a).isInternal) {
    case NIM_FALSE:
    T2_ = (NI)0;    for (T2_ = 0; T2_ < 512; T2_++) {   nimGCvisit((void*)(*a)._isInternal_1.vals[T2_], op);    }
    break;
    case NIM_TRUE:
    T3_ = (NI)0;    for (T3_ = 0; T3_ < 512; T3_++) {   nimGCvisit((void*)(*a)._isInternal_2.links[T3_], op);   }
    break;
    } 
}

for this code:

proc next*[Key, Val](b: BTree[Key, Val]; index: int): (Key, Val, int) =
  var it = b.root
  var i = index
  # navigate to the right leaf:
  while it.isInternal:
    var sum = 0
    for k in 0..<it.entries:
      let c = countSubTree(it.links[k])
      inc sum, c
      if sum > i:
        it = it.links[k]
        dec i, (sum - c)
        break
  result = (it.keys[i], it.vals[i], index+1)
timotheecour commented 4 years ago
#    /* consider using NULL if comment below for NIM_NIL doesn't apply to C++ */
#    define NIM_NIL 0

indeed https://stackoverflow.com/a/50766105/1426932 [ Note: In particular, neither the null pointer conversion for a zero-valued integral constant expression ([conv.ptr]) nor the derived-to-base conversion ([conv.ptr]) are applied. Although 0 is a valid template-argument for a non-type template-parameter of integral type, it is not a valid template-argument for a non-type template-parameter of pointer type. However, both (int*)0 and nullptr are valid template-arguments for a non-type template-parameter of type “pointer to int.” — end note ]

timotheecour commented 4 years ago

wrong error message in sigmatch: should show int instead of range 0..512(int)

proc bar(a: csize_t) = discard

proc fun[R](a: array[R, char]) =
  const N = high(a)
  static: doAssert N is int
  bar(N)

var a: array[0..512, char]
fun(a)
Error: type mismatch: got <range 0..512(int)>
but expected one of:
proc bar(a: csize_t)
  first type mismatch at position: 1
  required type for a: csize_t
  but expression 'N' is of type: range 0..512(int)

expression: bar(N)
    bar(N)
timotheecour commented 4 years ago

freebsd BUG getApplFreebsd

https://github.com/nim-lang/Nim/pull/12179/files#r399875661

timotheecour commented 4 years ago

track Documentation async by juancarlospaco · Pull Request #12979 · nim-lang/Nim : Documentation async by juancarlospaco · Pull Request #12979 · nim-lang/Nim

So, if we all agree on that, can we close this PR and use its content as a basis for doc/tut4.rst, which will be async tutorial?

timotheecour commented 4 years ago

track:

timotheecour commented 4 years ago

=> but doesn't mean we shouldn't test the code that runs csource, that code could regress; we ARE gonna need to rebuild csources at some point even if csources is frozen, to avoid keeping having to bootstrap from a really old compiler (so we can simplify nim code)

added Github workflow for checking if the documentation is still correct, no need to run kochExecFold("Docs", "docs --git.commit:devel") anymore on every PR

=> but now, nim doc only run from ubuntu; sometimes, these are our only tests

timotheecour commented 4 years ago

csources not being tested anymore

csources are now archived, no need to run kochExecFold("C sources", "csource") anymore

https://github.com/nim-lang/Nim/pull/13803#issuecomment-606354919

timotheecour commented 4 years ago
timotheecour commented 4 years ago

deprecate isNil(a: IntSet) since IntSet is an object; maybe use same treatment as isNil for string etc (user defined error)

timotheecour commented 4 years ago

Edited: null safe make some progresses now https://nim-lang.github.io/Nim/manual_experimental_strictnotnil.html

timotheecour commented 4 years ago

also, check whether https://github.com/nim-lang/Nim/pull/13818 is desirable on osx, or whether it prevents useful case of just opening browser

pending https://github.com/nim-lang/Nim/pull/13892

timotheecour commented 4 years ago
timotheecour commented 4 years ago

https://github.com/nim-lang/Nim/pull/13809#discussion_r401287070

what about tools/dochack which includes tools/dochack/dochack.nim?

timotheecour commented 4 years ago
timotheecour commented 4 years ago
timotheecour commented 4 years ago
timotheecour commented 4 years ago
timotheecour commented 4 years ago
timotheecour commented 4 years ago
timotheecour commented 4 years ago

using this:

nimbase.h should be tracked as a depdendency in the main.json file generated by --genscript and maybe also the generated main.deps file

timotheecour commented 4 years ago
timotheecour commented 4 years ago

D20200405T131708 macro pragma not overloadable

macro bar(body): untyped =
  body

template bar(a: int, b: string): untyped =
  discard

proc fun(a: int) {.bar.} =
  discard

and errmsg is bad: Error: redefinition of 'fun'; previous declaration here: /Users/timothee/git_clone/nim/timn/tests/nim/all/t10503.nim(11, 6) proc fun(a: int) {.bar.} = ^

timotheecour commented 4 years ago

show resolved types in errmsgs instead of useless:

but expected one of:
proc contains[T](x: set[T]; y: T): bool
  first type mismatch at position: 2
  required type for y: T
  but expression 'sfVarPragma' is of type: TSymFlag
6 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them

expression: contains(symi.flags, sfVarPragma)
          if sfVarPragma in symi.flags:
timotheecour commented 4 years ago

check this: # xxx: also check for nkRefTy as in opcLdDeref? see https://github.com/nim-lang/Nim/pull/13865/files#diff-df1f02d5585eaaa687dd520ca30be3faR801

timotheecour commented 4 years ago

add test case from https://github.com/timotheecour/vitanim/blob/master/testcases/tests/test_vm_var_importc.nim left over from VM: support importc var, ptr/pointer types, cast int <=> ptr/pointer by timotheecour · Pull Request #12877 · nim-lang/Nim : VM: support importc var, ptr/pointer types, cast int <=> ptr/pointer by timotheecour · Pull Request #12877 · nim-lang/Nim

timotheecour commented 4 years ago

rebuild logic should check nimbase.h (at least)

timotheecour commented 4 years ago

check whether noinit in some parts of stdlib suffer from this: https://github.com/dlang/phobos/pull/6178#discussion_r178309551

var a {.noinit.}: seq[Foo]
a.setLenUninitialized(n)
fillUp(a)

if fillUp throws before a was filled up, you may get garbage references that would never be released, causing memory leaks? which GC's could that affect? see whether suggestion proposed in that link works

timotheecour commented 4 years ago
timotheecour commented 4 years ago

--hints:off --hint:cc should work

timotheecour commented 4 years ago

nkNilLit shd be in nkLiterals

timotheecour commented 4 years ago

callDepthLimitReached should raise StackOverflowError (currently unused)

timotheecour commented 4 years ago

fmt: fmt"foo{b["title"]}bar" Error: could not parse b[.

timotheecour commented 4 years ago

adding --hint:cc:on should imply -f but doesnt'

timotheecour commented 4 years ago

I also added a new define (-d:noOpenSSLHacks)

should be -d:nimNoOpenSSLHacks to avoid name clashes

timotheecour commented 4 years ago

https://github.com/status-im/nim-stint/issues/103#issuecomment-612258174 (fix for https://github.com/status-im/nim-stint/issues/103 bundled in pr_misc)

timotheecour commented 4 years ago

fix this:

adding entries should not yield duplicate ABI checks, as enforced by typeABICache. Currently the test doesn't check for this but you can inspect the cgen'd file

in https://github.com/nim-lang/Nim/pull/13926/files

using c_currentSourcePath from https://github.com/nim-lang/Nim/pull/13953 (ie, tell whether ccodegen is correct wrt duplicate static assert checks)

timotheecour commented 4 years ago

lhmbp $nim_prs_D br:pr_fix_tnim_88_SIGSEGV_VM $ $(d_nim_bin).ffi.1 cpp --passC:-std=c++11 -d:timn_D20191207T181719 --app:lib -o:/tmp/libD20191211T004436.dylib $vitanim_D/testcases/tests/test_vm_var_importc_imp.nim

regression test case from test_vm_var_importc_imp.nim should be added to testament, see VM: support importc var, ptr/pointer types, cast int <=> ptr/pointer by timotheecour · Pull Request #12877 · nim-lang/Nim : VM: support importc var, ptr/pointer types, cast int <=> ptr/pointer by timotheecour · Pull Request #12877 · nim-lang/Nim

timotheecour commented 4 years ago

nim doesn't understand empty (or whitespace only) args in cmd line:

nim c --foo.bar.baz:' ' $timn_D/tests/nim/all/t10552.nim
command line(1, 2) Error: command expects a filename
timotheecour commented 4 years ago

C:\Users\timothee\git_clone\Nim>bin\nim_temp1.exe c --cc:vcc --warning:backendwarning:off -f --hint:conf:off tests/misc/mbackendwarnings.nim

=> nimbase.h(522): error C2118: negative subscript fails ABI test on windows

timotheecour commented 4 years ago

Error: VM does not support 'cast' from tyPointer to tyCString

timotheecour commented 4 years ago

unlike range[1..31], it's currently legal in Nim and doesn't give any warnings; if it becomes illegal or deprecated, this can be changed