Files
Nim/compiler
ringabout d77f5bcd0f fixes #25803: add genCppConstructorExpr for full type-prefixed expression (#25817)
fixes #25803

This pull request introduces a new approach for generating C++
constructor expressions in the Nim compiler's C++ backend, ensuring that
type-prefixed construction is used when needed (such as in assignments),
rather than just braced initializer lists. It also adds a new test case
(with corresponding C++ header) to verify correct behavior when
assigning to types with overloaded assignment operators and
constructors.

**C++ code generation improvements:**

* Added `genCppConstructorExpr` in `ccgtypes.nim`, which generates a
full type-prefixed constructor expression (e.g., `Foo(a, b)`) for C++
code generation, as opposed to just a braced initializer list. This is
important for contexts like assignments where the type must be explicit.
* Updated `resetLoc` in `cgen.nim` to use `genCppConstructorExpr`
instead of `genCppInitializer` when initializing imported C++ types,
ensuring correct code generation for assignments.

**Testing:**

* Added a new C++ header file, `tcpp_default_ctor_assignment.h`,
defining a struct `AmbiguousAssign` with overloaded assignment operators
and constructors to test ambiguous assignment scenarios.
* Added a corresponding Nim test, `tcpp_default_ctor_assignment.nim`,
which exercises construction and assignment for the imported C++ type,
ensuring the new code generation logic works as intended.
2026-07-02 12:04:43 +02:00
..
2023-12-15 10:20:57 +01:00
2025-12-01 22:59:12 +01:00
2026-06-25 23:20:34 +02:00
2026-06-11 14:10:42 +02:00
2026-02-10 13:21:35 +01:00
2026-06-14 22:35:06 +02:00
2026-06-14 22:35:06 +02:00
2026-06-25 23:20:34 +02:00
2026-06-14 22:35:06 +02:00
2026-06-25 23:20:34 +02:00
2026-06-14 22:35:06 +02:00
2026-06-24 21:58:51 +02:00
2025-12-31 13:33:57 +01:00
2017-01-07 22:35:09 +01:00
2026-02-10 13:21:35 +01:00
2026-06-14 22:35:06 +02:00
2025-12-11 18:22:38 +01:00
2025-12-11 18:22:38 +01:00
2026-06-25 23:20:34 +02:00
2025-11-25 12:49:23 +01:00
2026-04-02 07:19:43 +02:00
2024-12-27 19:42:18 +01:00
2026-06-14 22:35:06 +02:00
2026-04-02 07:19:43 +02:00
2026-06-25 23:20:34 +02:00
2025-12-11 18:22:38 +01:00
2026-04-02 07:19:43 +02:00
2026-06-14 22:35:06 +02:00
2026-06-25 23:20:34 +02:00
2021-01-12 09:36:51 +01:00
2026-06-24 21:58:51 +02:00
2026-06-25 23:20:34 +02:00
2026-01-09 13:10:04 +01:00
2026-06-14 22:35:06 +02:00
2026-06-24 21:58:51 +02:00
2026-06-24 21:58:51 +02:00
2025-12-11 18:22:38 +01:00
2026-06-14 22:35:06 +02:00
2026-06-14 22:35:06 +02:00
2026-02-10 13:21:35 +01:00
2023-07-02 22:36:05 +02:00
2023-11-06 18:33:28 +01:00
2026-06-15 23:33:16 +02:00
2026-06-24 21:58:51 +02:00
2025-12-11 18:22:38 +01:00
2026-06-14 22:35:06 +02:00
2026-06-24 21:58:51 +02:00
2026-06-14 22:35:06 +02:00
2025-12-11 18:22:38 +01:00
2025-12-11 18:22:38 +01:00
2026-06-25 23:20:34 +02:00
2026-06-24 21:58:51 +02:00
2026-06-25 23:20:34 +02:00
2026-06-25 23:20:34 +02:00
2026-06-14 22:35:06 +02:00
2024-03-16 08:35:18 +08:00
2026-06-24 21:58:51 +02:00
2026-06-25 23:20:34 +02:00
2025-12-31 13:33:57 +01:00
2026-06-25 23:20:34 +02:00
2026-06-25 23:20:34 +02:00
2026-06-14 22:35:06 +02:00
2023-12-25 07:12:54 +01:00

Nim Compiler

  • This directory contains the Nim compiler written in Nim.
  • Note that this code has been translated from a bootstrapping version written in Pascal.
  • So the code is not a poster child of good Nim code.

See Internals of the Nim Compiler for more information.