Commit Graph

79 Commits

Author SHA1 Message Date
ringabout
68b2e9eb6a make PNode.typ a private field (#24326) 2024-10-18 16:52:07 +02:00
metagn
1bebc236bd fix type of reconstructed kind field node in field checking analysis [backport] (#24290)
fixes #24021

The field checking for case object branches at some point generates a
negated set `contains` check for the object discriminator. For enum
types, this tries to generate a complement set and convert to a
`contains` check in that instead. It obtains this type from the type of
the element node in the `contains` check.

`buildProperFieldCheck` creates the element node by changing a field
access expression like `foo.z` into `foo.kind`. In order to do this, it
copies the node `foo.z` and sets the field name in the node to the
symbol `kind`. But when copying the node, the type of the original
`foo.z` is retained. This means that the complement is performed on the
type of the accessed field rather than the type of the discriminator,
which causes problems when the accessed field is also an enum.

To fix this, we properly set the type of the copied node to the type of
the kind field. An alternative is just to make a new node instead.

A lot of text for a single line change, I know, but this part of the
codebase could use more explanation.
2024-10-12 21:20:21 +02:00
ringabout
cca5684a17 fixes yet another strictdefs bug (#23069) 2023-12-15 08:13:25 +01:00
Andreas Rumpf
02be027e9b IC: progress and refactorings (#22961) 2023-11-20 21:12:13 +01:00
ringabout
e17237ce9d prepare for the enforcement of std prefix (#22873)
follow up https://github.com/nim-lang/Nim/pull/22851
2023-10-29 14:48:11 +01:00
ringabout
93ced31353 use strictdefs for compiler (#22365)
* wip; use strictdefs for compiler

* checkpoint

* complete the chores

* more fixes

* first phase cleanup

* Update compiler/bitsets.nim

* cleanup
2023-08-06 14:26:21 +02:00
Andreas Rumpf
0faae4d5e2 fixes a strict case object problem that has been reported on the forum (#20614) 2022-10-21 22:46:32 +02:00
Andreas Rumpf
76763f51aa implemented strictCaseObjects (#20608)
* implemented strictCaseObjects

* changelog update
2022-10-21 06:55:52 +02:00
metagn
de4b0346bd store full definition AST for consts, fix noRewrite (#20115)
* 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
2022-09-28 15:05:01 +02:00
flywind
7f6e800caf move assertions out of system (#19599) 2022-03-23 20:34:53 +01:00
Andreas Rumpf
cdf9ac675b this ensures libp2p continues to compile [backport] (#18908) 2021-09-27 19:25:00 +02:00
flywind
8d63f7b483 clean up old codes (#17071) 2021-02-17 19:26:08 +01:00
Andreas Rumpf
8241e55023 IC: next steps (#16729)
* IC: dead code elimination pass
* preparations for a different codegen strategy
* added documentation to the newly written code
* IC: backend code
* IC: backend adjustments
* optimized the compiler a bit
* IC: yet another massive refactoring
* fixes regressions
* cleanups
2021-01-23 08:06:15 +01:00
Andreas Rumpf
226595515c explicit ID generation for easier IC (#15559)
* 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)
2020-10-25 08:50:47 +01:00
Andreas Rumpf
da29222f86 init checks and 'out' parameters (#14521)
* I don't care about observable stores
* enforce explicit initializations
* cleaner code for the stdlib
* stdlib: use explicit initializations
* make tests green
* algorithm.nim: set result explicitly
* remove out parameters and bring the PR into a mergable state
* updated the changelog
2020-06-23 10:53:57 +02:00
Andreas Rumpf
3a2697dd73 drnim: tiny progress (#13882)
* drnim: tiny progress
* refactoring complete
* drnim: prove .ensures annotations
* Moved code around to avoid code duplication
* drnim: first implementation of the 'old' property
* drnim: be precise about the assignment statement
* first implementation of --assumeUnique
* progress on forall/exists handling
2020-04-15 20:03:25 +02:00
Andreas Rumpf
9ffec79300 DrNim (Nim compiler with Z3 integration) (#13743)
* code cleanups and feature additions
* added basic test and koch/CI integration
* make it build on Unix
* DrNim: now buildable on Unix, only takes 10 minutes, enjoy
* added basic documentation for DrNim which can also be seen as the RFC we're following
* drnim: change the build setup so that drnim.exe ends up in bin/
* makes simple floating point ranges work
* added basic float range check
* drnim: teach Z3 about Nim's range types plus code refactoring
* drnim: make unsigned numbers work
* added and fixed index checking under setLen
* first implementation of .ensures, .invariant and .assume (.requires still missing and so is proc type compatibility checking
* drnim: .requires checking implemented
* drnim: implemented .ensures properly
* more impressive test involving min()
* drnim: check for proc type compatibility and base method compatibility wrt .requires and .ensures
* testament: support for 'pattern <directory>
* koch: uses new <directory> feature of testament
* drnim: added tiny musings about 'old'
* Make testament work with old SSL versions
* koch: add support for 'koch drnim -d:release'
* drnim: preparations for the param.old notation
2020-03-31 22:54:48 +02:00
Andreas Rumpf
3f29911a94 new feature: --staticBoundChecks:on to enforce static array index checking (#10965) 2020-03-18 14:25:10 +01:00
Arne Döring
2f557652d4 fix operators containing percent for VM usage (#13536)
* fixes #13513
* merge tarithmetics in tarithm
2020-03-11 01:01:25 +01:00
Arne Döring
eb42f38088 Remove dead magics (#13551) 2020-03-03 12:42:43 +01:00
Clyybber
7e747d11c6 Cosmetic compiler cleanup (#12718)
* Cleanup compiler code base

* Unify add calls

* Unify len invocations

* Unify range operators

* Fix oversight

* Remove {.procvar.} pragma

* initCandidate -> newCandidate where reasonable

* Unify safeLen calls
2019-11-28 17:13:04 +01:00
Paul Tan
ad3c10022a guards.nim:sameTree(): handle uint literals correctly (#12483) [backport] 2019-10-22 18:18:33 +02:00
Clyybber
ed1d41c51e Small ast.nim cleanup (#12156)
* Remove sonsLen
* Use Indexable
2019-09-09 11:54:15 +02:00
Arne Döring
3d4ad9739c fix min/max for float numbers (#12068) 2019-09-02 11:21:26 +02:00
Arne Döring
afbcd1b330 int128 on firstOrd, lastOrd and lengthOrd (#11701)
* fixes #11847
2019-08-07 15:53:16 +02:00
Araq
296c48de5e fixes #11436 2019-06-19 09:48:55 +02:00
Clyybber
f18b3af9d4 Replace countup(x, y-1) with x ..< y 2019-05-07 12:32:05 +02:00
jcosborn
044cef152f add custom pragma support for var and let symbols (#9582)
* add custom pragma support for var and let symbols
* updated changelog for custom pragmas on var and let symbols
* add oldast switch for backwards compatibility
2019-01-07 12:36:06 +01:00
cooldome
eaca5be9d6 Change the order of compilation passes, transformation is made lazy at code gen (#8489)
* Ast no transformation
* Add getImplNoTransform to the macros module
* progress on delaying transf
* Fix methods tranformation
* Fix lazy lambdalifting
* fix create thread wrapper
* transform for lambda lifting
* improve getImplTransformed
* Fix destructor tests
* try to fix nimprof for linux
2018-10-18 20:21:25 +02:00
Andreas Rumpf
669a564492 remove more global variables in the Nim compiler 2018-05-27 11:10:56 +02:00
Andreas Rumpf
a4e2b0c153 platform.nim doesn't use globals anymore; prepare msgs.nim for not using globals 2018-05-18 15:18:00 +02:00
Andreas Rumpf
05724645f8 more modules compile again 2018-05-12 11:58:44 +02:00
Andreas Rumpf
2e76a92fe1 sempass2 compiles again 2018-05-11 14:18:39 +02:00
Andreas Rumpf
7eb39d9d26 guards.nim does compile 2018-05-11 13:07:16 +02:00
Arne Döring
6baca58693 Get symbol kind (#7491) 2018-04-11 16:48:01 +02:00
Andreas Rumpf
4f9e8cf313 macros.nim: deprecated ! operator 2017-11-19 13:23:04 +01:00
Andreas Rumpf
3fdb78fe80 fixes #5781 2017-11-18 21:47:14 +01:00
Andreas Rumpf
70ea45cdba deprecated unary '<' 2017-10-29 08:37:13 +01:00
Araq
aa4260ffa8 overloading resolution for getAst; breaking change 2017-03-18 20:57:45 +01:00
Araq
e6c5622aa7 removed tyArrayConstr completely from the compiler; introduced tyAlias instead in preparation for further bugfixes 2016-11-14 23:18:30 +01:00
Araq
29db0d8585 refactoring complete: explicit ident cache 2016-10-31 19:47:20 +01:00
Araq
773d17cd14 big refactoring: step 1 2016-10-31 15:34:44 +01:00
Andreas Rumpf
39ebe2175b compiler almost free of deprecated expr/stmt names 2016-07-30 16:34:42 +02:00
Araq
000c413f35 disjoint checker is smarter (and slower) 2015-09-23 21:46:34 +02:00
Araq
90d1ad4231 made disjoint checker smarter; fixes regressions 2015-09-23 21:46:32 +02:00
rku
47114342c4 Removed magics: mEqI64 mLtI64 mLeI64 2015-06-10 10:25:36 +03:00
rku
372a5d3cbb Removed magics: mAddI64, mSubI64, mMulI64, mDivI64, mModI64
Author:    rku <rokups@zoho.com>
2015-06-10 10:25:35 +03:00
Araq
3fa2e79814 sempass2: bugfixes 2015-04-28 15:01:05 +02:00
Araq
4be0d16520 added '..^' and '..<' operators; 'nil' is allowed for 'len'; added plugin system to the compiler 2015-04-22 12:04:11 +02:00
Araq
aacaa8f171 cleaned up some magics to make room for new magics; added '..<' and '..^' templates 2015-04-22 12:04:09 +02:00