summary refs log tree commit diff stats
path: root/tests/vm
Commit message (Collapse)AuthorAgeFilesLines
* fix `inTypeofContext` leaking after `compiles` raises exception ↵metagn2024-09-221-0/+7
| | | | | | | | | | | | | | | [backport:2.0] (#24152) fixes #24150, refs #22022 An exception is raised in the `semExprWithType` call, which means `dec c.inTypeofContext` is never called, but `compiles` allows compilation to continue. This means `c.inTypeofContext` is left perpetually nonzero, which prevents `compileTime` evaluation for the rest of the program. To fix this, `defer:` is used for the `dec c.inTypeofContext` call, as is done for [`instCounter`](https://github.com/nim-lang/Nim/blob/d51d88700b2fb3bd228d5e8f7385e2e4a2e2880c/compiler/seminst.nim#L374) in other parts of the compiler.
* make distinct conversions addressable in VM (#24124)metagn2024-09-171-0/+49
| | | | | | | | | | | | | | | | fixes #24097 For `nkConv` addresses where the conversion is between 2 types that are equal between backends, treat assignments the same as assignments to the argument of the conversion. In the VM this seems to be in `genAsgn` and `genAsgnPatch`, as evidenced by the special logic for `nkDerefExpr` etc. This doesn't handle ranges after #24037 because `sameBackendType` is used and not `sameBackendTypeIgnoreRange`. This is so this is backportable without #24037 and another PR can be opened that implements it for ranges and adds tests as well. We can also merge `sameBackendTypeIgnoreRange` with `sameBackendType` since it doesn't seem like anything that uses it would be affected (only cycle checks and the VM), but then we still have to add tests.
* open new scope for const values (#24084)metagn2024-09-092-0/+10
| | | | | | | | | | | | | fixes #5395 Previously values of `const` statements used the same scope as the `const` statement itself, meaning variables could be declared inside them and referred to in other statements in the same block. Now each `const` value opens its own scope, so any variable declared in the value of a constant can only be accessed for that constant. We could change this to open a new scope for the `const` *section* rather than each constant, so the variables can be used in other constants, but I'm not sure if this is sound.
* fixes #21353; fixes default closure in the VM (#24070)ringabout2024-09-091-0/+4
| | | | | | | | | | | | | fixes #21353 ```nim result = newNodeIT(nkTupleConstr, info, t) result.add(newNodeIT(nkNilLit, info, t)) result.add(newNodeIT(nkNilLit, info, t)) ``` The old implementation uses `t` which is the type of the closure function as its type. It is not correct and generates ((nil, nil), (nil, nil)) for `default(closures)`. This PR creates `(tyPointer, tyPointer)` for fake closure types just like what cctypes do.
* proper error for calling nil closure in VM (#24059)metagn2024-09-042-0/+31
| | | | | | fixes #24057 Instead of crashing the compiler, the VM now gives a stacktrace if a nil closure is attempted to be called.
* fixes #23925; VM generates wrong cast for negative enum values (#23951)autumngray2024-08-271-0/+24
| | | | | | | | | | Follow up of #23927 which solves the build error. This is still only a partial fix as it doesn't take into account unordered enums. I'll make a separate issue for those. --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* adds a ubuntu 24.04 matrix with gcc 14 for tests (#23673)ringabout2024-08-201-1/+1
| | | ref https://forum.nim-lang.org/t/11587
* make all generic aliases tyAlias (#23978)metagn2024-08-201-1/+1
| | | | | | | | | | | | | fixes #23977 The problem is that for *any* body of a generic declaration, [semstmts](https://github.com/nim-lang/Nim/blob/2e4d344b43b040a4dce2c478ca13e49979e491fc/compiler/semstmts.nim#L1610-L1611) sets the sym of its value to the generic type name, and [semtypes](https://github.com/nim-lang/Nim/blob/2e4d344b43b040a4dce2c478ca13e49979e491fc/compiler/semtypes.nim#L2143) just directly gives the referenced type *specifically* when the expression is a generic body. I'm blaming `semtypes` here because it's responsible for the type given but the exact opposite behavior specifically written in makes me think generating an alias type here maybe breaks something.
* allow generic compileTime proc folding (#22022)metagn2024-08-181-0/+29
| | | | | | | | | | | | | | fixes #10753, fixes #22021, refs #19365 (was fixed by #22029, but more faithful test added) For whatever reason `compileTime` proc calls did not fold if the proc was generic ([since this folding was introduced](https://github.com/nim-lang/Nim/commit/c25ffbf2622a197c15a4a3bd790b1bc788db2c7f#diff-539da3a63df08fa987f1b0c67d26cdc690753843d110b6bf0805a685eeaffd40)). I'm guessing the intention was for *unresolved* generic procs to not fold, which is now the logic. Non-magic `compileTime` procs also now don't fold at compile time in `typeof` contexts to avoid possible runtime errors (only the important) and prevent double/needless evaluation.
* fixes #23932; vmopsDanger for os.getCurrentDir errors (#23934)ringabout2024-08-111-2/+5
| | | | fixes #23932 ref https://github.com/jmgomez/NimForUE/issues/36
* closes #22095; adds a test case (#23822)ringabout2024-07-111-0/+20
| | | closes #22095
* fixes #22389; fixes #19840; don't fold paths containing `addr` (#23807)ringabout2024-07-091-0/+15
| | | | fixes #22389; fixes #19840
* fixes #13481; fixes #22708; disable using union objects in VM (#23362)ringabout2024-03-031-8/+0
| | | | | | fixes #13481; fixes #22708 Otherwise it gives implicit results or bad codegen
* fixes #12334; keeps `nkHiddenStdConv` for cstring conversions (#23216)ringabout2024-01-181-0/+10
| | | | | | fixes #12334 `nkHiddenStdConv` shouldn't be removed if the sources aren't literals, viz. constant symbols.
* give typedesc param nodes type T not typedesc[T] [backport:2.0] (#23115)metagn2024-01-182-2/+14
| | | | | | | fixes https://github.com/nim-lang/Nim/issues/23112, fixes a mistake in https://github.com/nim-lang/Nim/pull/22581 This makes `getType(t)` where `t` is a typedesc param with value `T` equal to `getType(T)`.
* fix isNil folding for compile time closures (#22574)metagn2023-09-021-0/+8
| | | fixes #20543
* use dummy dest for void branches to fix noreturn in VM (#22617)metagn2023-09-011-0/+32
| | | fixes #22216
* don't update const symbol on const section re-sems (#22609)metagn2023-09-011-0/+10
| | | fixes #19849
* handle typedesc params in VM (#22581)metagn2023-08-302-2/+21
| | | | | | | | | * handle typedesc params in VM fixes #15760 * add test * fix getType(typedesc) test
* clearer error for different size int/float cast in VM (#22582)metagn2023-08-291-0/+3
| | | refs #16547
* fix getNullValue for cstring in VM, make other VM code aware of nil cstring ↵metagn2023-08-211-0/+31
| | | | | | | | | | | | | (#22527) * fix getNullValue for cstring in VM fixes #22524 * very ugly fixes, but fix #15730 * nil cstring len works, more test lines * fix high
* Add staticFileExists and staticDirExists (#22278)Tomohiro2023-08-181-0/+2
|
* close #18103 internal error: inconsistent environment type (#22451)Bung2023-08-111-0/+35
|
* add a test case for #22190 in case of regression (#22217)ringabout2023-07-041-0/+21
|
* alternative to #22183; nimscript shares the same compileTime sym with VM ↵ringabout2023-06-292-0/+16
| | | | (#22184)
* fix VM uint conversion size bug, stricter int gen on JS (#22150)metagn2023-06-251-0/+7
| | | | | | | | | | | * fix VM uint conversion bug, stricter int gen on JS fixes #19929 * fix float -> uint64 conversion too * no need to mask to source type * simpler diff with explanation, add test for described issue
* allow addressing elements of openArray[char] in VM (#22045)ringabout2023-06-081-0/+14
| | | allow addressing elements of openArray[char]
* some test cleanups & category reorganization (#22010)metagn2023-06-064-0/+131
| | | | | | | | | | | | | | | | | * clean up some test categories * mention exact slice issue * magics into system * move trangechecks into overflow * move tmemory to system * try fix CI * try fix CI * final CI fix
* fixes #21708; skip colons for tuples in VM (#21850)ringabout2023-05-171-0/+10
| | | | | | | * fixes #21708; skip colon for tuples in VM * skip nimnodes * fixes types
* closes #7590; add a test case (#21846)ringabout2023-05-141-0/+20
|
* clean up SOME pending/xxx/issue link comments (#21826)metagn2023-05-111-1/+1
| | | | | * clean up SOME pending/xxx/issue link comments * great
* fixes #21704; remove nfIsRef for genLit in VM (#21765)ringabout2023-05-061-0/+69
| | | | | | | | | | | | | * fixes #21704; remove `nfIsRef` for genLit * remove nfIsRef from the output of macros * make the logic better * try again * act together * excl nfIsRef
* closes #10108; add a test case (#21770)ringabout2023-05-031-10/+22
|
* fixes #19863; move sha1, md5 to nimble packages for 2.0 (#21702)ringabout2023-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * move sha1, md5 to nimble packages * boot the compiler * fixes tests * build the documentation * fixes docs * lol, I forgot koch.nim * add `nimHasChecksums` define * clone checksums but maybe copying is better * bump nimble hash * use ChecksumsStableCommit * fixes tests * deprecate them * fixes paths * fixes koch
* stdlib tests now check refc too (#21664)ringabout2023-04-211-1/+1
| | | | | | | | | | | * stdlib tests now check refc too * typo * fixes line numbers * disable cpp * do not touch
* fixes explicit globals in macros (#21502)ringabout2023-03-121-0/+13
|
* fixes #10938; fixes #13312; fixes #13918; fixes #20985; always initializes ↵ringabout2023-03-011-2/+44
| | | | | | | | | | | global variables with null values in VM (#21351) * fixes #10938; always initialize global variable in VM * fixes importc vars * there is a pre-existing issue regarding closure types in the VM * add tests
* closes #17864; add a test case (#21434)ringabout2023-02-251-0/+12
|
* fixes #16790; fixes #19075; put big arrays on the constant seqs; don't ↵ringabout2023-01-311-0/+19
| | | | | | | inline them in the VM; big performance boost (#21318) * don't inline arrays in VM * add a test for #19075
* fix #21045; getTime with vmopsDanger is broken; alternative to #21054 (#21056)ringabout2022-12-101-0/+10
| | | | | * fix #21045 getTime with vmopsDanger is broken; alternative to #21054 * typo
* fixes regression #20746; remove string copies for ORC booted compiler (#20776)ringabout2022-11-071-0/+13
| | | | | | | | | | | | | * fixes #20746; remove string copies for ORC booted compiler * add a test case * use `cursor` thanks to @beef331 * for old compilers * change file extension * change test cases
* fixes regression #17121; adding doc comment in importc proc makes it ↵ringabout2022-11-061-0/+9
| | | | | | | | | silently noop at CT (#20766) * fixes regression #17121; adding doc comment in importc proc makes it silently noop at CT * Update compiler/vmgen.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #19201; fixes sink causes crash in VM (#20658)ringabout2022-10-251-1/+7
|
* Unpack mSlice tupleconstr for static openarrays (#20615)Jason Beetham2022-10-221-0/+4
|
* closes #19969; add testcase for #19969 #15952 #16306 (#20610)ringabout2022-10-211-0/+27
| | | closes #19969; add testcase
* Implemented `mSlice` on the VM allowing `toOpenArray` to work at compile ↵Jason Beetham2022-10-201-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | time. (#20586) * Implemented opcSlice to make 'toOpenArray' work on the VM * Added nkOpenArray for VM to reduce bodgeness * Fixed range issues and erraneous comments * Range check correctly for openArrays in opcLdArr * Inverted logic for ldArr checking * vm now supports slicing strings * Added string tests * Removed usage of 'nkOpenArray' and redundant operations * Refactored vmSlice implementation, removing redundant and incorrect code * Made tuples go throw opcWrObj for field assignment * All strkinds should be considered for openarrays
* 'lock levels' are deprecated, now a noop (#20539)ringabout2022-10-111-1/+1
| | | | | * 'lock levels' are deprecated, now a noop * fixes tests
* closes #12994; add testcase (#20511)ringabout2022-10-081-0/+23
|
* moderate system cleanup & refactor (#20355)metagn2022-09-281-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * system refactor, move out 600 lines * compilation, slice, backwardsindex, misc_num moved out of system * some procs/types moved into arithmetics, basic_types * system no longer depends on syncio * some procs moved around to fit with their surroundings * make exceptions an import, old ops to misc_num * move instantiationInfo back * move back nim version, fix windows echo * include compilation * better docs for imported modules, fix unsigned ops also remove ze, ze64, toU8, toU16, toU32 with nimPreviewSlimSystem * fix terminal * workaround IC test & weird csize bug, changelog * move NimMajor etc back to compilation, rebase for CI * try ic fix * form single `indices`, slim out TaintedString, try fix IC * fix CI, update changelog, addQuitProc * fix CI * try fix CI * actually fix CI finally hopefully * Update lib/system/compilation.nim Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * update kochdocs * hopefully fix csize uses for slimsystem * fix tquit Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* remove echo statements in tests (part 1) (#20178)ringabout2022-08-238-40/+6
| | | | | | | | | | | * remove echo statements * Update tests/vm/triangle_array.nim * Update tests/vm/tyaytypedesc.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>