Commit Graph

58 Commits

Author SHA1 Message Date
ringabout
58b1f28177 fixes implicitConv discarding flags (#24817)
follow up https://github.com/nim-lang/Nim/pull/24809
ref https://github.com/nim-lang/Nim/pull/24815
2025-03-28 12:52:45 +01:00
ringabout
ddd83f8d8a fixes #24800; Invalid C code generation with a method, case object in refc (#24809)
fixes #24800

This PR avoids a conversion from `sink T` to `T`

I will add a test case
2025-03-25 20:42:40 +01:00
metagn
38ad336c69 fix tuple nodes from VM inserting hidden conv to keep old type (#24756)
fixes #24755, refs #24710

Instead of using the node from `indexTypesMatch` which inserts a hidden
conv node, just change the type of the node back to the old type
directly
2025-03-11 10:00:37 +01:00
metagn
49dfc3a0d4 convert tuple constructors from VM back to original types (#24710)
fixes #24698

The same aim as #24224 but for tuple constructors. The difference here
is that the type of a tuple constructor is always going to be valid
unlike array constructors which can have `seq` etc types, so we can just
generate a conversion again. If the conversion fails, it is ignored
similar to #24611, this is to protect against modified typed nodes in
macros.

Also #24611 was only adapted to `semTupleFieldsConstr` and not
`semTuplePositionsConstr`, this is now fixed.
2025-02-26 22:20:41 +01:00
metagn
8d0e853e0a ignore match errors to expected types of tuple constructor elements (#24611)
fixes #24609

A tuple may have an incompatible expected type if there is a converter
match to it. So the compiler should not error when trying to match the
individual elements in the constructor to the elements of the expected
tuple type, this will be checked when the tuple is entirely constructed
anyway.
2025-01-15 20:01:56 +01:00
metagn
cfd69bad1a fix wrong subtype relation in tuples & infer some conversions (#23228)
fixes #18125

Previously a tuple type like `(T, int)` would match an expected tuple
type `(U, int)` if `T` is a subtype of `U`. This is wrong since the
codegen does not handle type conversions of individual tuple elements in
a type conversion of an entire tuple. For this reason the compiler
already does not accept `(float, int)` for a matched type `(int, int)`,
however the code that checked for which relations are unacceptable
checked for `< isSubtype` rather than `<= isSubtype`, so subtypes were
not included in the unacceptable relations.

Update: Now only considered unacceptable when inheritance is used, as in
[`paramTypesMatch`](3379d26629/compiler/sigmatch.nim (L2252-L2254)).
Ideally subtype relations that don't need conversions, like `nil`,
`seq[empty]`, `range[0..5]` etc would be their own relation
`isConcreteSubtype` (which would also allow us to differentiate with
`openArray[T]`), but this is too big of a refactor for now.

To compensate for this making things like `let x: (Parent, int) =
(Child(), 0)` not compile (they would crash codegen before anyway but
should still work in principle), type inference for tuple constructors
is updated such that they call `fitNode` on the fields and their
expected types, so a type conversion is generated for the individual
subtype element.
2024-01-18 21:19:29 +01:00
metagn
53d43e9671 round out tuple unpacking assignment, support underscores (#22537)
* round out tuple unpacking assignment, support underscores

fixes #18710

* fix test messages

* use discard instead of continue

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2023-08-24 06:11:48 +02:00
ringabout
77beb15214 fixes #22049; fixes #22054; implicit conversion keeps varness (#22097)
* fixes #22054; codegen for var tuples conv

* rethink fixes

* add test cases

* templates only

* fixes var tuples

* keep varness no matter what

* fixes typ.isNil

* make it work for generics

* restore isSubrange

* add a test case as requested
2023-06-16 12:06:50 +02:00
metagn
2315b01ae6 tuple unpacking for vars as just sugar, allowing nesting (#21563)
* 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
2023-03-28 17:52:23 +02:00
ringabout
841d9d5975 closes #16331; add testcase (#20730) 2022-11-02 12:01:36 +08:00
flywind
9df195ef58 style usages part one (openarray => openArray) (#19321)
* style usages (openArray)

* revert doc changes
2022-01-04 13:29:50 +01:00
Jason Beetham
ed44618deb Fixed const tuples in inferred generics (#18598) 2021-07-27 09:36:59 +02:00
flywind
9c52009de6 close #7012 add testcase (#17537) 2021-03-27 10:12:11 -07:00
Timothee Cour
7b9b76d840 tests/tuples/ttuples_issues.nim: test on all backends + various improvements (#16907)
* improve tests/tuples/ttuples_issues.nim: test on all backends

* address comments
2021-02-02 20:17:13 +01:00
flywind
358963193f cleanup old codes (#16173) 2020-11-30 09:41:50 +08:00
Clyybber
5bd2da3f64 Fix #14911 (#14922) [backport]
* Fix #14911

* Add testcase

* Fix test
2020-07-07 10:21:18 +02:00
hlaaftana
76ffa4fa25 fixes #14112, tests for #12892, #12671, #11697 (#14125) 2020-04-26 10:12:16 +02:00
Nindaleth
34dbc5699e fix several typos in documentation and comments (#12553) 2019-10-30 09:08:45 +01:00
Federico Ceratto
39290cf88c Fix spellings (#12277) [backport] 2019-09-27 07:02:54 +02:00
Arne Döring
2339542832 Tuple error message (#11141); fixes #3211 2019-05-15 17:59:06 +02:00
Andreas Rumpf
cd79c6f532 Merge pull request #11159 from JasperJenkins/const-named-tuple-unpack
Const named tuple unpacking
2019-05-08 17:50:41 +02:00
nc-x
e42c304e4a Fix loop tuple unpacking in templates (#11174)
* Fix loop tuple unpacking in templates

* Add test
2019-05-05 12:22:41 +02:00
Jasper Jenkins
0add3a6dc0 enable t9177. 2019-05-01 22:37:38 -07:00
Jasper Jenkins
8a6b416c28 const named tuple unpacking 2019-05-01 22:18:45 -07:00
deech
68a82f100e Fixes #10727. (#10728) 2019-02-25 11:21:14 +01:00
Neelesh Chandola
9884129058 Tuple unpacking now works for for vars (#10152)
* Tuple unpacking now works for `for` vars
* Give error if length of tuple vars != length of tuple
* Fix error message showing wrong tuple length
* unpacking now works now for mutable items
* Update changelog
2019-02-23 14:01:34 +01:00
Andreas Rumpf
444f2231c9 make tests green again 2019-02-08 16:54:12 +01:00
LemonBoy
aa6e40abe6 Fix wrong result in tuple assignment (#9340)
Fixes #9177
2019-02-08 12:24:03 +01:00
Miran
5345c5b130 remove deprecated modules (#10215)
* removed from `compiler`:
    * lists (deprecated 2 years ago)

* removed from `lib` (all deprecated 3 years ago):
    * ssl
    * matchers
    * httpserver

* removed from `lib/deprecated`:
    * unsigned
    * actors (and three accompanying tests)
    * parseurl

* moved to `lib/deprecated`:
    * securehash (the reason for not directly removing - it was deprecated (only) one year ago)
2019-01-07 10:37:49 +01:00
ee7
cc4720fac1 Const tuple unpacking: add tests (#10100) 2018-12-27 22:40:40 +01:00
Arne Döring
a5ecbf823f lots of small changes 2018-12-11 21:23:22 +01:00
Arne Döring
1105d03644 require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
Miran
66a76d3165 Merge tests into a larger file (part 8 of ∞) (#9583)
* merge tuple tests

* merge trmacros tests

* merge template tests
2018-11-06 18:33:58 +01:00
Araq
420ed0596b fixes more nil handling regressions 2018-08-13 17:27:44 +02:00
Arne Döring
efae366857 rename SomeReal to SomeFloat (#7617)
* rename SomeReal to SomeFloat
* added changelog entry
2018-04-15 19:59:11 +02:00
Andreas Rumpf
47335aab41 introduce nkTupleConstr AST node for unary tuple construction; breaking change 2018-04-13 17:45:58 +02:00
Araq
be87fe9176 make tests green again 2017-12-15 13:24:47 +01:00
Arne Döring
000b8afd26 Remove expr/stmt (#5857) 2017-07-25 09:28:23 +02:00
Andreas Rumpf
920888f382 fixes tuple unpacking regression 2017-04-26 11:10:50 +02:00
cooldome
c6a8bd264e Fix for #5695 make subscript operator overloadable for tuples (#5749) 2017-04-24 20:17:06 +02:00
Andreas Rumpf
471672fecc fix: generic tuples instantiations were cached incorrectly 2016-07-28 20:23:24 +02:00
Matthew Baulch
915185dd11 Handle tuples with unnamed fields, symbols, and more. Less duplication. 2016-07-15 20:36:11 +10:00
Matthew Baulch
de41649b0e Use target field types in tuple conversions. 2016-07-14 20:51:40 +10:00
Andreas Rumpf
07d7d35d99 fixes #3579 2016-06-05 18:50:52 +02:00
Federico Ceratto
d9cb85c2d8 Spellcheck 2016-02-29 11:25:51 +00:00
Araq
bfd2fd67f9 tuple unpacking works in a non-var/let context 2015-08-21 21:34:14 +02:00
Dominik Picheta
ad6ad5d8d0 s/procedure/routine/ in tests. 2015-06-05 14:53:49 +01:00
Dominik Picheta
5d6f16cc1a Got rid of errUndeclaredProcedureField. 2015-06-04 16:39:38 +01:00
Dominik Picheta
22f6017ab8 Fixes #2584
Better compiler errors for accessing undeclared fields, calling undeclared
procedures and procedure fields.
2015-06-04 13:55:48 +01:00
Araq
0e1167d64b made test green 2015-05-03 01:08:53 +02:00