summary refs log tree commit diff stats
path: root/tests/macros
Commit message (Collapse)AuthorAgeFilesLines
* consider calling convention and iterator in getType for procs (#24181)metagn2024-09-272-3/+31
| | | | | | | | | fixes #19010 `getType` for proc types generated an `nkProcTy` for iterator types instead of `nkIteratorTy`, and didn't generate a calling convention pragma unless it was in the proc AST. Iterator types now generate `nkIteratorTy`, and a calling convention pragma is added if the calling convention isn't `closure` or was explicitly provided.
* render float128 literals (#24182)metagn2024-09-271-0/+7
| | | | | | fixes #23639 Not sure if these are meant to be supported but it's better than crashing.
* generic issues test cases (#24028)metagn2024-08-301-0/+61
| | | | | | | | | | | | | closes #1969, closes #7547, closes #7737, closes #11838, closes #12283, closes #12714, closes #12720, closes #14053, closes #16118, closes #19670, closes #22645 I was going to wait on these but regression tests even for recent PRs are turning out to be important in wide reaching PRs like #24010. The other issues with the working label felt either finnicky (#7385, #9156, #12732, #15247), excessive to test (#12405, #12424, #17527), or I just don't know what fixed them/what the issue was (#16128: the PR link gives a server error by Github, #12457, #12487).
* Set type of object constructor during annotateType (#23852)SirOlaf2024-07-171-0/+23
| | | | | | Fix https://github.com/nim-lang/Nim/issues/23547 Tested locally with the included test, the test from constantine and the original issue.
* fixes #23784; don't allow fold paths containing `nkAddr` (#23792)ringabout2024-07-031-0/+157
| | | | | | | fixes #23784 notes that before https://github.com/nim-lang/Nim/pull/23477, it didn't fold paths containing `addr`/`unsafeAddr` because it retained the form of the magic function: `mAddr`.
* fixes addr/hiddenAddr in strictdefs (#23477)ringabout2024-04-101-1/+1
|
* closes #15751; adds a test case (#23372)ringabout2024-03-061-0/+11
| | | closes #15751
* Changing generic weight of `tyGenericParam` (#22143)Ryan McConnell2024-01-051-2/+0
| | | | | | | | | | | | This is in reference to a [feature request](https://github.com/nim-lang/Nim/issues/22142) that I posted. I'm making this PR to demonstrate the suggested change and expect that this should be scrutinized --------- Co-authored-by: Bung <crc32@qq.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* ambiguous identifier resolution (#23123)metagn2024-01-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #23002, fixes #22841, refs comments in #23097 When an identifier is ambiguous in scope (i.e. multiple imports contain symbols with the same name), attempt resolving it through type inference (by creating a symchoice). To do this efficiently, `qualifiedLookUp` had to be broken up so that `semExpr` can access the ambiguous candidates directly (now obtained directly via `lookUpCandidates`). This fixes the linked issues, but an example like: ```nim let on = 123 {.warning[ProveInit]: on.} ``` will still fail, since `on` is unambiguously the local `let` symbol here (this is also true for `proc on` but `proc` symbols generate symchoices anyway). Type symbols are not considered to not confuse the type inference. This includes the change in sigmatch, up to this point symchoices with nonoverloadable symbols could be created, they just wouldn't be considered during disambiguation. Now every proper symbol except types are considered in disambiguation, so the correct symbols must be picked during the creation of the symchoice node. I remember there being a violating case of this in the compiler, but this was very likely fixed by excluding type symbols as CI seems to have found no issues. The pure enum ambiguity test was disabled because ambiguous pure enums now behave like overloadable enums with this behavior, so we get a longer error message for `echo amb` like `type mismatch: got <MyEnum | OtherEnum> but expected T`
* retain postfix node in type section typed AST, with docgen fix (#23101)metagn2023-12-232-1/+8
| | | | | | Continued from #23096 which was reverted due to breaking a package and failing docgen tests. Docgen should now work, but ~~a PR is still pending for the package: https://github.com/SciNim/Unchained/pull/45~~ has been merged
* Don't crash for invalid toplevel parseStmt/Expr calls (#23089)Jake Leahy2023-12-191-0/+15
| | | | | | | | | | | | | | | This code will crash `check`/`nimsuggest` since the `ra` register is uninitialised ```nim import macros static: discard parseExpr("'") ``` Now it assigns an empty node so that it has something Testament changes were so I could properly write a test. It would pass even with a segfault since it could find the error
* Revert "retain postfix node in type section typed AST" (#23098)metagn2023-12-192-8/+1
| | | Reverts nim-lang/Nim#23096
* retain postfix node in type section typed AST (#23096)metagn2023-12-182-1/+8
| | | fixes #22933
* Mark `macros.error` as `.noreturn.` (#23081)Jake Leahy2023-12-171-0/+4
| | | | | | | | | | | | | | | Closes #14329 Marks `macros.error` as `.noreturn` so that it can be used in expressions. This also fixes the issue that occurred in #19659 where a stmt that could be an expression (Due to having `discardable` procs at the end of other branches) would believe a `noreturn` proc is returning the same type e.g. ```nim proc bar(): int {.discardable.} = discard if true: bar() else: quit(0) # Says that quit is of type `int` and needs to be used/discarded except it actually has no return type ```
* Allow `parseAll` to parse statements separated by semicolons (#23088)Jake Leahy2023-12-171-0/+4
| | | | | | | | | | | | | | | | | | Fixes the second issue listed in #9918. Fixed by replacing the logic used in `parseAll` with just a continious loop to `complexOrSimpleStmt` like what the [normal parser does](https://github.com/nim-lang/Nim/blob/devel/compiler/passes.nim#L143-L146). `complexOrSimpleStmt` [guarantees progress](https://github.com/nim-lang/Nim/blob/devel/compiler/parser.nim#L2541) so we don't need to check progress ourselves. Also allows `nimpretty` to parse more valid Nim code such as ```nim proc foo(); # Would complain about indention here # ... proc foo() = # ... ```
* Param match relax (#23033)Ryan McConnell2023-12-153-2/+44
| | | | | | | | | | | #23032 --------- Co-authored-by: Nikolay Nikolov <nickysn@gmail.com> Co-authored-by: Pylgos <43234674+Pylgos@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Jason Beetham <beefers331@gmail.com>
* case macro now can be used inside generic. Fixes #20435 (#22752)Juan M Gómez2023-09-301-0/+30
| | | | | | | | | fixes #20435 --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Jake Leahy <jake@leahy.dev> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* test case haul for old generic/template/macro issues (#22564)metagn2023-08-271-0/+31
| | | | | | | | | | | | * test case haul for old generic/template/macro issues closes #12582, closes #19552, closes #2465, closes #4596, closes #15246, closes #12683, closes #7889, closes #4547, closes #12415, closes #2002, closes #1771, closes #5121 The test for #5648 is also moved into its own test from `types/tissues_types` due to not being joinable. * fix template gensym test
* fixes overriden typo (#22044)ringabout2023-06-081-2/+2
|
* clean up SOME pending/xxx/issue link comments (#21826)metagn2023-05-111-2/+0
| | | | | * clean up SOME pending/xxx/issue link comments * great
* fix #15691 (#21623)metagn2023-04-111-0/+22
| | | `semProcAux` has a check for `checkMinSonsLen(n, bodyPos + 1)`
* macros: Extend treeTraverse intVal range to nnkUInt64Lit (#21597)chmod2222023-04-011-0/+13
| | | | | | | | | * Extend intVal range to nnkUInt64Lit Fixes #21593 * Properly cast intVal as unsigned * Add testcase for #21593
* tuple unpacking for vars as just sugar, allowing nesting (#21563)metagn2023-03-281-1/+3
| | | | | | | | | | | | | | | | | | | * tuple unpacking for vars as just sugar, allowing nesting * set temp symbol AST * hopeful fix some issues, add test for #19364 * always use temp for consts * document, fix small issue * fix manual indentation * actually fix manual * use helper proc * don't resem temp tuple assignment
* Add `contains` to `std/macrocache` (#21304)Jake Leahy2023-02-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add test cases * Implement contains for CacheSeq * Implement contains for CacheTable * Fix implementation of hasKey * Remove contains for CacheSeq Fix runnable examples I was accidently using --doccmd:skip so I didn't spot the failure locally * Implement hasKey as a VM callback instead of magic * Implement suggestions from PR Co-Authored-By: ringabout <ringabout@users.noreply.github.com> * Update lib/core/macrocache.nim --------- Co-authored-by: ringabout <ringabout@users.noreply.github.com> Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Implement setLineInfo (#21153)Peter Munch-Ellingsen2022-12-221-1/+22
| | | | | * Implement setLineInfo * Add tests
* fix #16758 Nim crashes in fixAbstractType (#20855)Bung2022-12-111-0/+38
| | | | | | | | | * fix #16758 Nim crashes in fixAbstractType * Update compiler/semexprs.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* store full definition AST for consts, fix noRewrite (#20115)metagn2022-09-282-1/+17
| | | | | | | | | | | | | | | | | | | | | | | * continue #9582 for consts, close #9331, fix #20114 also move extractPragma to ast to pave the way for things like {.strdefine: "abc".} etc * changelog correctly * fix jsgen * update tgetimpl * fix sighashes * fix #19766, add comment about postfix * fix noRewrite LOL refs #16620 * fix changelog * fix destructors
* defaults to ORC (#19972)ringabout2022-09-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * defaults to Orc * bootstrap using refc * use gc * init orc defines * unregister orc * fix gc * fix commands * add prepareMutation for orc * enable deepcopy for orc * prepareMutation * more fixes * some cases * bug #20081 * partial fixes * partial fixes * fixes command line * more fixes * build Nim with refc * use gc * more fixes * rstore * orc doesn't support threadpool * more shallowCopy * more fixes * fixes unsafeNew * workarounds * small * more fixes * fixes some megatest * tcodegenbugs1 refc * fxies megatest * build nimble with refc * workaround tensordsl tests * replace shallowCopy with move * fixes action * workaround * add todo * fixes important packages * unpublic unregisterArcOrc * fixes cpp * enable windows Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
* remove deprecated type pragma syntax, fix bugs that required it (#20199)metagn2022-09-032-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | * remove deprecated pragma syntax from 0.20.0 closes #4651, closes #16653 with a cheap fix for now due to how early `tfFinal` is set * remove type pragma between name and generics * undo removal, try removing bind expression (0.8.14) * fix test, unremove bind expr * remove again * Update changelog.md Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * dependencies @ HEAD & weave test dependencies * try fix package ci Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* new .redefine pragma for templates, warn on redefinition without it (#20211)metagn2022-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test CI for template redefinitions * adapt asyncmacro * fix quote * fix again * try something else * revert * fix ioselectors_select, disable packages CI * adapt more tests & simplify * more * more * more * rename to redefine, warn on implicit redefinition * basic documentation [skip ci] * Update compiler/lineinfos.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* fix #20067, fix #18976 [backport] (#20069)metagn2022-07-221-0/+28
|
* fix NimNode comment repr() regression [backport: 1.2] (#19726)flywind2022-04-251-0/+19
|
* Allow std/macros.params to work with nnkProcTy (#19563)Tanguy2022-02-251-0/+22
| | | | | * Allow std/macros.params to work with nnkProcTy * Add tests for proc params & pragma
* [testcase] genSym fails to make unique identifier for ref object types (#19506)flywind2022-02-141-0/+60
| | | close #15118
* accept object type node from macros (#19179)hlaaftana2021-11-241-0/+16
|
* parseExpr/parseStmt accept filename, fixes #13540 (#19182)hlaaftana2021-11-242-0/+15
|
* `caseStmtMacros` no longer experimental, experimental manual refactor (#19173)hlaaftana2021-11-231-2/+0
| | | | | | | | | | | * `caseStmtMacros` no longer experimental, experimental manual refactor * Update doc/manual.rst * apply review suggestions * apply review Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #14511 [backport:1.4] (#18732)Dankr4d2021-08-251-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | * fixes #14511 [backport:1.4] Signed-off-by: Dankr4d <dude569@freenet.de> * Replaced fix with code from alaviss, for better readability, with small changes. Signed-off-by: Dankr4d <dude569@freenet.de> * - Specified output in test. Signed-off-by: Dankr4d <dude569@freenet.de> * Replaced case in nnkRecCase with a simpler version, which just adds the last son. Signed-off-by: Dankr4d <dude569@freenet.de> * Update tests/macros/t14511.nim * Update tests/macros/t14511.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Fix doubly typed forward declarations (#18279)Clyybber2021-06-161-1/+21
| | | | | | | | | * Add testcase * Fix testcase * Fix doubly typed forward decls * Better fix
* Don't report unused hints for consumed AST (#18270)Clyybber2021-06-161-0/+15
| | | | | | | | | * Fix #18203 * Add testcase * Fix testcase * Fix test
* fixes #18235 - proc annotation type macro sym leak (#18249)Saem Ghani2021-06-142-0/+60
| | | | | | | | | | | | | | | | | | | | | * fixes #18235 - proc annotation type macro sym leak - also fixed a typo - proc annotations guard symbol exports with shadow scopes - symbol handling is shadow scope aware * test for exporting an existing unexported sym this one is for my homie alaviss. * Special handling not needed in semProcAnnotation * Testcasing * [skip ci] clean-up and add some more comments * [skip ci] rm trailing whitespace Co-authored-by: Clyybber <darkmine956@gmail.com>
* getType now works with tyInferred (arising from concepts); refs #18220 (#18241)Timothee Cour2021-06-121-22/+78
| | | | | | | * getType now works with tyInferred (concepts); refs #18220 * avoid cast * add more docs
* macros.treeRepr + friends: collapse SymChoice (#18072)Timothee Cour2021-06-051-28/+108
| | | | | | | * macros.treeRepr + friends: collapse SymChoice * make repr+friends work with invalid symchoice nodes * address comment
* Fixes #5034 illformed AST from getImpl with proc returning value (#17976)Dylan Modesitt2021-05-311-0/+31
| | | | | * Fixes 5034 * address comments
* fix #17836 (typed macro isNil for proc params) (#17841)Saem Ghani2021-04-251-0/+15
| | | thanks @alaviss for the test
* close #7875 add testcase (#17611)flywind2021-04-021-0/+22
| | | | | * close #7875 add testcase * fix
* unify tuple expressions (#13793)Arne Döring2021-03-301-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * unify tuple expressions * fix test * fix test * apply feedback * Handle empty tuples * Fix rendering named unary tuple * Protect static NimNode against stripping * Slightly less hacky * Revert "Slightly less hacky" This reverts commit 170c5aec0addc029f637afbc948700ca006b7942. * Slightly less hacky * Cleanup * Fix test * Fix another test * Add condsym * Rebase fallout * changelog: Move from compiler changes to language changes * Add stricter tests * Add empty tuple example to doc/astspec * Fix test Co-authored-by: Clyybber <darkmine956@gmail.com>
* nnkArglist => nnkArgList + special case stylecheck:error (#17529)Timothee Cour2021-03-271-1/+1
| | | | | * nnkArglist => nnkArgList * special case stylecheck:error
* Remove support for named procs with sugar.=> (#17220)konsumlamm2021-03-051-8/+2
| | | | | | * Add docs & tests for named procs with sugar.=> * Remove support for named procs in sugar.=> * Resolve conflict * Fix test
* rename case statement macro from match to `case` (#16923)hlaaftana2021-02-081-0/+35
| | | | | * rename case statement macro from match to `case` * fix test