summary refs log tree commit diff stats
path: root/tests/pragmas
Commit message (Collapse)AuthorAgeFilesLines
* only merge valid implicit pragmas to routine AST, include templates (#24171)metagn2024-09-261-0/+12
| | | | | | | | | | | | | fixes #19277, refs #24169, refs #18124 When pragmas are pushed to a routine, if the routine symbol AST isn't nil by the time the pushed pragmas are being processed, the pragmas are implicitly added to the symbol AST. However this is done without restriction on the pragma, if the pushed pragma isn't supposed to apply to the routine, it's still added to the routine. This is why the symbol AST for templates wasn't set before the pushed pragma processing in #18124. Now, the pragmas added to the AST are restricted to ones that apply to the given routine. This means we can set the template symbol AST earlier so that the pragmas get added to the template AST.
* fixes #24167; {.push deprecated.} for templates (#24170)ringabout2024-09-251-0/+6
| | | fixes #24167
* fix custom pragma with backticks not working [backport] (#24151)metagn2024-09-221-0/+7
| | | refs https://forum.nim-lang.org/t/12522
* fixes push warnings for sempass2 (#23603)ringabout2024-09-031-0/+13
| | | ref https://forum.nim-lang.org/t/11590
* allow qualifying macro pragmas (#23985)metagn2024-08-202-0/+24
| | | fixes #12696
* [backport] fixes #23711; C code contains backtick`gensym (#23716)ringabout2024-06-191-0/+25
| | | fixes #23711
* ambiguous identifier resolution (#23123)metagn2024-01-013-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`
* Don't process a user pragma if its invalid (#23041)Jake Leahy2023-12-071-0/+9
| | | | | | | | | | | | | | | When running `check`/`suggest` in a file with an invalid user pragma like ```nim {.pragma foo: test.} ``` It will continue to try and process it which leads to the compiler running into a `FieldDefect` ``` fatal.nim(53) sysFatal Error: unhandled exception: field 'sons' is not accessible for type 'TNode' using 'kind = nkIdent' [FieldDefect] ``` This makes it instead bail out trying to process the user pragma if its invalid
* fixes #23019; Regression from 2.0 to devel with raise an unlisted exc… ↵ringabout2023-12-051-0/+22
| | | | | | | | | | (#23034) …eption: Exception fixes #23019 I suppose `implicitPragmas` is called somewhere which converts `otherPragmas`.
* fixes #22913; fixes #12985 differently push-ing pragma exportc genera… ↵ringabout2023-11-191-0/+39
| | | | | | | | | | | (#22941) …tes invalid C identifiers fixes #22913 fixes #12985 differently `{.push.} now does not apply to generic instantiations`
* Fix #22713: Make size unknown for tyForward (#22714)SirOlaf2023-09-171-0/+12
| | | | | | | Close #22713 --------- Co-authored-by: SirOlaf <>
* allow non-pragma special words as user pragmas (#22526)metagn2023-08-211-0/+5
| | | | | allow non-pragma special words as macro pragmas fixes #22525
* fixes #22362; Compiler crashes with staticBoundsCheck on (#22363)ringabout2023-08-021-0/+13
|
* some test cleanups & category reorganization (#22010)metagn2023-06-067-202/+0
| | | | | | | | | | | | | | | | | * 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
* error on user pragma args (#21776)metagn2023-05-031-0/+5
| | | closes #20978
* custom pragmas: correct error condition, remove outdated symkind whitelist ↵metagn2023-04-133-2/+52
| | | | | | | | | | | | | | | (#21653) * test not restricting custom pragma applied symbols fixes #21652 * fix other test * different patch * fix tests * actually test #18212 and other routines
* add a prepass for codeReordering (#21513)ringabout2023-03-171-1/+0
| | | | | | | * add a prepass for codeReordering * simplify * fixes
* fixes #19795; fixes #11852; fixes #19974; remove parsing pipeline, Nim now ↵ringabout2023-02-222-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | parses the whole module at one time (#21379) * fixes #19795; remove parse pipeline * isScript * fixes nimscriptapi * don't touch reorder * check script * fixes tests * it seems implicit imports of system cause troubles * access the first child of `nkStmtList` * ignore comments * minor messages * perhaps increases hloLoopDetector * the module is a stmtList, which changes the errors * fixes nimdoc * fixes tlinter * fixes nim secret tests * fixes arc_misc * fixes nim secret tests again * safe; fixes one more test * GlobalError is the root cause too * fixes parsing errors * put emit types to the cfsForwardTypes section * fixes #11852; `{.push checks:off}` now works in procs * disable navigator * fixes nimdoc * add tests for JS * fixes nimsuggest
* fixes pragmas reorder (#21205)ringabout2023-01-011-0/+19
|
* Check file exists in `{.compile.}` pragma (#21105)Jake Leahy2022-12-151-0/+5
| | | | | | | | | * Add test * Check file exists before adding it into compilation * Make error message look like other error messages i.e. following the format `error msg: file`
* 'lock levels' are deprecated, now a noop (#20539)ringabout2022-10-111-4/+0
| | | | | * 'lock levels' are deprecated, now a noop * fixes tests
* close #11415; add testcase (#20486)ringabout2022-10-031-0/+25
|
* store full definition AST for consts, fix noRewrite (#20115)metagn2022-09-281-0/+40
| | | | | | | | | | | | | | | | | | | | | | | * 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-232-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Allow custom pragma on iterators [backport] (#20344)Tanguy2022-09-171-0/+7
| | | Allow custom pragma on iterators
* [Testament] Extend and document message testing aids (#19996)quantimnot2022-09-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * [Testament] Extend and document message testing aids * Enable inline msgs when not reject action. Eliminates the pain of changing the line and column numbers in `nimout` or `output` while making changes to the test. * Enable using inline msgs and nimout together. Allows ease of inline msgs for the test as well as testing msgs from other modules. * Add path separator and test filename variable interpolation in msgs. Eases handling path separators in the msgs. * Add some documentation. * Fixed lots of broken tests * Fixed more broken tests * Support multiple inline messages per a line * Fix a broken test * Revert variable substitution in `output` * Remove uneeded params * Update doc/testament.md Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Update testament/specs.nim Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Update testament/specs.nim Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Fix indentation Co-authored-by: quantimnot <quantimnot@users.noreply.github.com> Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* fixes #18612; apply cache and memcmp for methods in arc/orc (#19749)flywind2022-04-261-0/+3
| | | | | | | | | | | | | | | | | * try using endsWith * use memcmp * add cache * cleanup * better * minor * fix * improve test coverage for methods with ARC
* Clonkk fix2 11923 (#19451)Regis Caillaud2022-02-021-0/+6
| | | | | | | * fix nnkBracketExpr not compiling for getImpl on customPragmaNode * fix test import * fix alias not working with hasCustomPragmas
* New/better macro pragmas, mark some as experimental (#19406)metagn2022-01-202-9/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * New/better macro pragmas, make some experimental fix #15920, close #18212, close #14781, close #6696, close https://github.com/nim-lang/RFCs/issues/220 Variable macro pragmas have been changed to only take a unary section node. They can now also be applied in sections with multiple variables, as well as `const` sections. They also accept arguments. Templates now support macro pragmas, mirroring other routine types. Type and variable macro pragmas have been made experimental. Symbols without parentheses instatiating nullary macros or templates has also been documented in the experimental manual. A check for a redefinition error based on the left hand side of variable definitions when using variable macro pragmas was disabled. This nerfs `byaddr` specifically, however this has been documented as a consequence of the experimental features `byaddr` uses. Given how simple these changes are I'm worried if I'm missing something. * accomodate compiler boot * allow weird pragmas * add test for #10994 * remove some control flow, try remove some logic
* Fix #11923 (#19427)Regis Caillaud2022-01-201-0/+10
| | | | | * Apply commit https://github.com/nim-lang/Nim/commit/5da931fe811717a45f2dd272ea6281979c3e8f0b that was never merged (was part of a bigger PR). Should fix issue #11932 * add a generic object for custom pragma
* Accept nnkTypeSection from typedef macro pragmas (#19168)hlaaftana2021-11-221-0/+66
|
* fixes another effect inference bug [backport:1.6] (#19100)Andreas Rumpf2021-11-071-0/+1
| | | | * fixes another effect inference bug [backport:1.6]
* Removes deprecated {.injectStmt.}. Fixes #18666 (#18984)Dominik Picheta2021-10-131-51/+0
|
* strict effects (#18777)Andreas Rumpf2021-09-021-1/+2
| | | | | | | | | | | | | | | | | * fixes #17369 * megatest is green for --cpu:arm64 * docgen output includes more tags/raises * implemented 'effectsOf' * algorithm.nim: uses new effectsOf annotation * closes #18376 * closes #17475 * closes #13905 * allow effectsOf: [a, b] * added a test case * parameters that are not ours cannot be declared as .effectsOf * documentation * manual: added the 'sort' example * bootstrap with the new better options
* improvements to `addInt` and `$` for integer types (#18592)Timothee Cour2021-08-191-5/+8
| | | | | | | | * improvements to $(SomeInteger) and addInt * remove mIntToStr, mInt64ToStr * improvements * fix tests/pragmas/tinjectstmt.nim; the diff is harmless, cgen code is identical with -d:danger or debug mode * rm tests/system/tstrmantle.nim * revert compiler/jsgen.nim for -d:nimVersion140
* fix: `var a{.foo.} = expr` inside templates (refs #15920) (except when `foo` ↵Timothee Cour2021-08-111-0/+52
| | | | | | | | | | | is overloaded) (#13869) * fix: `var a{.foo.} = expr` inside templates * add test * improve tdecls test * improve tests * add failing test * PRTEMP * fixup
* fixes #18543 (#18601)Andreas Rumpf2021-07-271-12/+13
| | | | | * fixes #18543 * make tests green again
* followup #18362: make `UnusedImport` work robustly (#18366)Timothee Cour2021-06-273-0/+129
| | | | * warnDuplicateModuleImport => hintDuplicateModuleImport * improve DuplicateModuleImport msg, add test
* even lighter version of #17938: fix most issues with UnusedImport, ↵Timothee Cour2021-06-264-0/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | XDeclaredButNotUsed, etc; fix #17511, #17510, #14246 (without realModule) (#18362) * {.used: symbol} * add tests * fix tests with --import * --import works without giving spurious unused warnings * new warning warnDuplicateModuleImport for `import foo; import foo` * fix test, add resolveModuleAlias, use proper line info for module aliases * fix spurious warnings * fix deprecation msg for deprecated modules even with `import foo as bar` * disable a test for i386 pending sorting XDeclaredButNotUsed errors * UnusedImport now works with re-exported symbols * fix typo [skip ci] * ic support * add genPNode to allow writing PNode-based compiler code similarly to `genAst` * fix DuplicateModuleImport warning * adjust test * fixup * fixup * fixup * fix after rebase * fix for IC * keep the proc inline, move the const out * [skip ci] fix changelog * experiment: remove calls to resolveModuleAlias * followup * fixup * fix tests/modules/tselfimport.nim * workaround tests/deprecated/tmodule1.nim * fix properly * simplify
* move {.injectStmt.} to experimental; add a test (#18300)Timothee Cour2021-06-201-0/+48
| | | | | * move {.injectStmt.} to experimental; add a test * undocument and deprecat `.injectStmt` but keep its implementation until we have a replacement
* change `--hint[X] => --hint:X` in nim repo (avoids shell quoting issues) ↵Timothee Cour2021-05-261-1/+1
| | | | (#18085)
* getCustomPragmaVal priority/override fixes (#17725)Clyybber2021-04-211-0/+10
| | | | | | | | | * Adhere left-to-right rule for custom pragma priority * Improve error message for no custom pragmas * custom pragmas on var/let sym take priority over its type ones * Workaround & bug
* Fix getCustomPragmaVal for some multi arg pragmas (#17723)Clyybber2021-04-151-0/+9
| | | | | * Fix getCustomPragmaVal for some multi arg pragmas * Bootstrap fix
* simplify asyncfutures, asyncmacro (#17633)Timothee Cour2021-04-141-13/+7
|
* getCustomPragma is split up in more usable chunks (#11526)Arne Döring2021-04-141-3/+27
| | | | | | | | | | | | | | | | | * getCustomPragma is split up in more usable chunks * changelog entry * fix for style checks * shitty typedesc special casing * Add since annotation and remove typedesc comments * Fix typo * Revert since annotation because it breaks bootstrapping * Export getCustomPragmaNode conditionally * Reduce code duplication * Update since * Update lib/core/macros.nim * Apply suggestions from code review Co-authored-by: Clyybber <darkmine956@gmail.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fix #16693: testament spec nimout too lax (#16698)flywind2021-04-042-2/+18
| | | Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
* disable hint:processing in tests (#16713)Timothee Cour2021-01-141-0/+1
| | | | | * disable hint:processing in tests * fix test
* use doAssert in tests (#16486)flywind2020-12-282-35/+35
|
* fix #12558 (#15864)flywind2020-11-091-0/+15
| | | | * fix #12558 * Update compiler/pragmas.nim
* close #8457 (#15844)flywind2020-11-051-0/+11
|