summary refs log tree commit diff stats
path: root/compiler/pragmas.nim
Commit message (Collapse)AuthorAgeFilesLines
* Check file exists in `{.compile.}` pragma (#21105)Jake Leahy2022-12-151-2/+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`
* generic `define` pragma + string alias (#20979)metagn2022-12-131-7/+16
| | | | | | | | | * generic `define` pragma + string alias * clean * add tests and document * remove char/float, minimize changelog
* fixes #20026; marks system procs which can raise defects (#20864)ringabout2022-11-221-1/+3
| | | | | | | | | * marks system procs which can raise defects * add tests * add more systemRaisesDefect * add comment
* 'lock levels' are deprecated, now a noop (#20539)ringabout2022-10-111-18/+1
| | | | | * 'lock levels' are deprecated, now a noop * fixes tests
* pragma for sfCallsite instead of name check + better semantics, test (#20464)metagn2022-10-031-1/+4
| | | | | | | | | | | * pragma for sfCallsite instead of name check at every template definition Not documented because it seems to be for internal use? Should also make it possible to make comparisons and setops imports, but this doesn't have to be done. I can reuse a name like `cursor` for the pragma as well, added a new name just to be safe. * make sfCallsite recursive, add tests
* store full definition AST for consts, fix noRewrite (#20115)metagn2022-09-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | * 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
* no ropes WIP (#20433)Andreas Rumpf2022-09-271-2/+2
| | | | | | | | | | | | | * refactorings in preparation for ropes elimination of the C code generator; mostly the usual ': Rope' -> 'result: var Rope' rewrite * rewrote ccgcalls.nim * refactored ccgexprs.nim * ccgliterals: refactoring * refactoring: code dealing with name mangling * refactoring: getRecordFieldsAux * ropes are strings (insert obscene joke here) * optimize JS code gen * optimizations and code improvements * more optimizations * final cleanups
* Allow custom pragma on iterators [backport] (#20344)Tanguy2022-09-171-1/+1
| | | Allow custom pragma on iterators
* remove unused sfProcvar, "procvar" mentions (#20204)metagn2022-08-241-2/+1
| | | refs #12975. doesn't close it because wProcvar isn't removed
* new .redefine pragma for templates, warn on redefinition without it (#20211)metagn2022-08-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Add `doctype: RST|Markdown|RstMarkdown` pragma (#20252)Andrey Makarov2022-08-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | * Add `doctype: RST|Markdown|RstMarkdown` pragma Implements https://github.com/nim-lang/RFCs/issues/68 , see also discussion in https://github.com/nim-lang/Nim/issues/17987 The permitted values: * `markdown`, which is default. It still contains nearly all of the RST supported but it is assumed that in time we will give up most or all RST features in this mode * `rst`, without any extensions * `RstMarkdown` — compatibility with Nim 1.x. It's basically RST with those Markdown features enabled that don't conflict with RST. * Apply suggestions from code review Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Additional fix in spirit of review * Fix test after #20188 Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* remove {.this.} pragma, deprecated since 0.19 (#20201)metagn2022-08-231-9/+0
| | | Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* remove shallowCopy for ARC/ORC (#20070)ringabout2022-07-261-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | * remove shallowCopy for ARC/ORC * use move * fix * more fixes * typo * Update lib/system.nim * follow * add nodestroy * move * copy string * add a changelog entry Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* .forbids pragma: defining forbidden tags (#20050)Lancer112112022-07-261-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * .forbids pragma: defining illegal effects for proc types This patch intends to define the opposite of the .tags pragma: a way to define effects which are not allowed in a proc. * updated documentation and changelogs for the forbids pragma * renamed notTagEffects to forbiddenEffects * corrected issues of forbids pragma the forbids pragma didn't handle simple restrictions properly and it also had issues with subtyping * removed incorrect character from changelog * added test to cover the interaction of methods and the forbids pragma * covering the interaction of the tags and forbids pragmas * updated manual about the forbids pragma * removed useless statement * corrected the subtyping of proc types using the forbids pragma * updated manual for the forbids pragma * updated documentations for forbids pragma * updated nim docs * updated docs with rsttester.nim * regenerated documentation * updated rst docs * Update changelog.md Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * updated changelog * corrected typo Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Change `styleCheck` to ignore foreign packages (#19822)quantimnot2022-07-141-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change `styleCheck` to ignore foreign packages * Symbols from foreign packages are now ignored. * Fixed `styleCheck` violations in `compiler` package. * Added symbol ownership to custom annotation pragmas. * Minor refactors to cleanup style check callsites. * Minor internal documentation of reasons why a symbol isn't checked. Style violations were fixed in the compiler after thet were exposed by the changes. The compiler wouldn't compile otherwise. Symbol ownership for custom pragma annotations is needed for checking the annotation's style. A NPE was raised otherwise. Fixes #10201 See also nim-lang/RFCs#456 * Fix a misunderstanding about excluding field style checks I had refactored the callsites of `styleCheckUse` to apply the DRY principle, but I misunderstood the field access handling in a template as a general case. This corrects it. * Fix some `styleCheck` violations in `compiler/evalffi` The violations were exposed in CI when the compiler was built with libffi. * Removed some uneeded transitionary code * Add changelog entry Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
* Refactor and doc package handling, module name mangling (#19821)quantimnot2022-05-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor and doc package handling, module name mangling * Consolidate, de-duplicate and extend package handling * Alter how duplicate module names of a package are handled * Alter how module names are mangled * Fix crash when another package is named 'stdlib' (test case added) * Doc what defines a package in the manual Modules with duplicate names within a package used to be given 'fake' packages to resolve conflicts. That prevented the ability to discern if a module belonged to the current project package or a foreign package. They now have the proper package owner and the names are mangled in a consistent manner to prevent codegen clashes. All module names are now mangled the same. Stdlib was treated special before, but now it is same as any other package. This fixes a crash when a foreign package is named 'stdlib'. Module mangling is altered for both file paths and symbols used by the backends. Removed an unused module name to package mapping that may have been intended for IC. The mapping was removed because it wasn't being used and was complicating the issue of package modules with duplicate names not having the proper package owner assigned. * Fix some tests * Refactor `packagehandling` * Remove `packagehandling.withPackageName` and its uses * Move module path mangling from `packagehandling` to `modulepaths` * Move `options.toRodFile` to `ic` to break import cycle * Changed import style to match preferred style Co-authored-by: quantimnot <quantimnot@users.noreply.github.com>
* fixes #14318 (#14335)Andreas Rumpf2022-03-261-1/+1
|
* fixes #19603; some pragmas were really only supported as top level ↵Andreas Rumpf2022-03-261-6/+9
| | | | statements. Now this is enforced properly. (#19646)
* move assertions out of system (#19599)flywind2022-03-231-0/+3
|
* fixes #19078 [backport] (#19090)Andreas Rumpf2021-11-021-1/+3
|
* Removes deprecated {.injectStmt.}. Fixes #18666 (#18984)Dominik Picheta2021-10-131-7/+1
|
* strict effects (#18777)Andreas Rumpf2021-09-021-4/+26
| | | | | | | | | | | | | | | | | * 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
* properly fix #10053 ; `FieldDefect` msg now shows discriminant value + ↵Timothee Cour2021-08-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lineinfo, in all backends (c,vm,js) (#11955) * fix #10053 FieldError for vm * fixup * FieldError now also shows runtime value of discriminant * fix field error reporting in vm * also report culprit line info in err msg * fix errors for newruntime 2 * fix for js * fixup * PRTEMP4 * works * works * works perfect * refactor * std/private/repr_impl * suppport --gc:arc * cleanup * refactor * simplify * simplify * simplify * fixup * move out compiler.vmgen.genCustom * fixup * fixup * add tests * revert compiler/debugutils.nim * simplify reprDiscriminant * fixup * lib/std/private/repr_impl.nim -> lib/system/repr_impl.nim * try to fix D20210812T165220 * honor --declaredlocs * control toFileLineCol via --declaredlocs
* move {.injectStmt.} to experimental; add a test (#18300)Timothee Cour2021-06-201-2/+3
| | | | | * move {.injectStmt.} to experimental; add a test * undocument and deprecat `.injectStmt` but keep its implementation until we have a replacement
* refs #18278: do not gag fatal msgs (#18290)Timothee Cour2021-06-181-1/+1
|
* add colon (#17834)flywind2021-04-241-1/+1
|
* IC: green tests (#17311)Andreas Rumpf2021-03-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * IC: renamed to_packed_ast module to ic module * IC: don't store the --forceBuild flag, makes it easier to test * IC: enable hello world test * Codegen: refactorings for IC; changed the name mangling algorithm * fixed the HCR regressions * life is too short for HCR * tconvexhull is now allowed to use deepCopy * IC exposed a stdlib bug, required a refactoring * codegen: code cleanups * IC: even if a module is outdated, its dependencies might come from disk * IC: progress * IC: better name mangling, module IDs are not stable * IC: another refactoring helping with --ic:on --gc:arc * disable arraymancer on Windows for the time being * disable arraymancer altogether * IC: make basic test work with 'nim cpp' * IC: progress on --ic:on --gc:arc * wip; name mangling for type info
* semLambda removed, semProcAux reworked (#17379)Saem Ghani2021-03-171-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * simplified proc-like name ident to symbol code * wip - reworking generic param sem * wip - closer to removing nkEmpty generic params * it's hacky but tests pass * slowly tweaking semProcAux to take on semLambda * fix pragma superset check proto vs current * Set the symbol owner earlier * partial progress reworking proto found bug where default values between forward and impl lead to overload resolution issues. * simplified pragma handling and callConv checks Co-authored-by: Clyybber <Clyybber@users.noreply.github.com> * partially working * cgexprs issue * It works! * comment clean-up * clean-up asserts, comments, and other bits * add isGenericParams, inline isGeneric queries * seeing if this is sufficiently consistent * can use this approach or continue it in a further PR * commentary about nullary generics and clean-ups * fixed a mistake in PNode isGenericRoutine * Some small cleanups * Small cleanup * for func lambdas ensure we use lambda pragmas * add some basic compileTime func tests * [ci skip] remove comments Co-authored-by: Clyybber <Clyybber@users.noreply.github.com> Co-authored-by: Clyybber <darkmine956@gmail.com>
* Remove declPragmas from lambdas [backport:1.0] (#16966)hlaaftana2021-02-091-6/+7
| | | | | | | | | * Remove declPragmas from lambdas [backport:1.0] * add test for exportc * fix test * fix align, nodecl -> noinit
* fix #16752: threadvar now works with importcpp types; osx now uses native ↵Timothee Cour2021-01-271-1/+3
| | | | | | | | | | | TLS (`--tlsEmulation:off`), which can be orders of magnitude faster (#16750) * osx now uses native TLS, which can be orders of magnitude faster * add {.cppNonPod.} * improve test * changelog, docs, disable part of windows test
* `--hintAsError` (#16763)Timothee Cour2021-01-201-0/+1
| | | | | | | * --hintAsError * add test, changelog * condsyms
* IC: next steps (#16632)Andreas Rumpf2021-01-121-3/+3
| | | | | | | | | | | | | * removed dead code * beginnings of a rodfile reader * IC: record global VM state changes and pragma state changes * IC: replay pragmas and VM state changes * implemented rod load file simuation for easier, extensive testing * critical bugfix * IC: stress test logic; should also help with recursive module dependencies; WIP * IC: loading from .rod files begins to work reliably * removed ugly hacks * yet another silly mistake
* IC: next steps (#16550)Andreas Rumpf2021-01-071-0/+4
| | | | | | | | | | | | | | | | | | * cleanups * ast.nim: cleanups * IC: no more sym.tab field, stored externally in the module graph * nimble compiles again * rodfiles: store bitwidth of integers and the endianness in the cookie because we serialize 'int' directly * rodfiles: added compilerproc and export sections * rodfiles: added all the missing sections * rodfiles: track the missing information * IC: architecture for lazy loading of proc bodies * make tests green again * completed the lazy loading of proc bodies * symbol lookup integration, part 1 * symbol lookup integration, part 2 * symbol lookup integration, part 3 * make tcompilerapi work again * rodfiles: fixed config change handling
* big steps torwards an efficient, simple IC implementation (#16543)Andreas Rumpf2021-01-021-6/+4
| | | | | | | | | | | | | | | | | | | * reworked ID handling * the packed AST now has its own ID mechanism * basic serialization code works * extract rodfiles to its own module * rodfiles: store and compare configs * rodfiles: store dependencies * store config at the end * precise dependency tracking * dependency tracking for rodfiles * completed loading of PSym, PType, etc * removed dead code * bugfix: do not realloc seqs when taking addr into an element * make IC opt-in for now * makes tcompilerapi green again * final cleanups Co-authored-by: Andy Davidoff <github@andy.disruptek.com>
* refactorings to prepare the compiler for IC (#15935)Andreas Rumpf2020-12-171-1/+3
| | | | | | | | | | | | | | * added ic specific Nim code; WIP * make the symbol import mechanism lazy; WIP * ensure that modules can be imported multiple times * ambiguity checking * handle converters and TR macros properly * make 'enum' test category green again * special logic for semi-pure enums * makes nimsuggest tests green again * fixes nimdata * makes nimpy green again * makes more important packages work
* cmdline: improve command processing (#16056)Timothee Cour2020-11-261-1/+1
|
* fix #12558 (#15864)flywind2020-11-091-1/+5
| | | | * fix #12558 * Update compiler/pragmas.nim
* EnumUtils, speed up findStr in compiler (#15777)cooldome2020-11-031-1/+1
| | | | | | | | * add parseEnumRange * fix runnable example * update changelog * use parseEnumRange in compiler * reorganise code * add changelog, make single normalizer argument
* Use modern enums in compiler (#15775)cooldome2020-11-021-7/+7
|
* closes #7658 (#15784)flywind2020-10-301-3/+6
| | | | | * fix #7658 * more
* explicit ID generation for easier IC (#15559)Andreas Rumpf2020-10-251-4/+4
| | | | | | | | | | | | | | | | | * refactoring: idents don't need inheritance * refactoring: adding an IdGenerator (part 1) * refactoring: adding an IdGenerator (part 2) * refactoring: adding an IdGenerator (part 3) * refactoring: adding an IdGenerator (part 4) * refactoring: adding an IdGenerator (part 5) * refactoring: adding an IdGenerator (part 5) * IdGenerator must be a ref type; hello world works again * make bootstrapping work again * progress: add back the 'exactReplica' ideas * added back the missing exactReplica hacks * make tcompilerapi work again * make important packages green * attempt to fix the build for 32 bit machines (probably need a better solution here)
* implements https://github.com/nim-lang/RFCs/issues/260 (#15505)Andreas Rumpf2020-10-071-10/+20
| | | | | * implements https://github.com/nim-lang/RFCs/issues/260 * added a test case
* implements https://github.com/nim-lang/RFCs/issues/258 (#15503)Andreas Rumpf2020-10-061-0/+9
| | | | | | | | | * implements https://github.com/nim-lang/RFCs/issues/258 * don't be too strict with custom pragma blocks * cast pragmas: documentation * added most missing inference query procs to effecttraits.nim
* fixes #15430, pop pragma takes invalid input (#15449)shirleyquirk2020-10-011-1/+3
| | | | | * fix #15430, pop pragma {.pop, experimental.} should be allowed, but not {.pop experimental.}
* .noalias annotation; frontend support (#15419)Andreas Rumpf2020-09-281-2/+6
| | | | | * .noalias annotation; frontend support * added .noalias support to Nim; implements https://github.com/nim-lang/RFCs/issues/204
* Expand hoisted default params in sem (#15270)Clyybber2020-09-051-3/+3
| | | | | | | | | * Expand hoisted default params in sem Introduce ast.newTree{I,IT} Add test for default params in procs * Cleanup * Simplify hoist transformation and expand test
* Big compiler Cleanup (#14777)Clyybber2020-08-281-3/+3
|
* Use typeflag insteadClyybber2020-08-101-2/+4
|
* Make explicit {.nimcall.} a seperate calling conventionClyybber2020-08-081-3/+3
|
* fixes #14458 [backport:1.2] (#14756)Andreas Rumpf2020-06-221-1/+1
|