Closed treeform closed 3 weeks ago
Defining a converter:
converter uniformUnwrap[T](v: Uniform[T]): T = v
Does not help. This is not a distinct type should just work.
Looks like defining a converter that goes to and from works:
Nim Compiler Version 2.0.10 [Linux: amd64]:
type
GVec2[T] = object
x, y: T
type
Uniform[T] = T
converter fromU[T](v: Uniform[T]): T = v
converter toU[T](v: T): Uniform[T] = v
proc foo(v: Uniform[GVec2[float32]]) =
echo v.x
let f = GVec2[float32](x: 1.0f, y: 2.0f)
foo(f)
!nim c
type
GVec2[T] = object
x, y: T
type
Uniform[T] = T
proc foo(v: Uniform[GVec2[float32]]) =
echo v.x
let f = GVec2[float32](x: 1.0f, y: 2.0f)
foo(f)
0 (0 bytes)
```cpp
```
2024-11-07T18:07:48
2024-11-07T18:07:49
0 (0 bytes)
```cpp
```
2024-11-07T18:07:53
2024-11-07T18:07:53
0 (0 bytes)
```cpp
```
2024-11-07T18:07:57
2024-11-07T18:07:57
91.52 Kb (93,712 bytes)
```cpp
#include "nimbase.h"
#define nimfr_(proc, file) \
TFrame FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
#define nimfrs_(proc, file, slots, length) \
struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename;NI len;VarSlot s[slots];} FR_; \
FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
#define nimln_(n) \
FR_.line = n;
#define nimlf_(n, file) \
FR_.line = n; FR_.filename = file;
typedef struct tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA {
NF32 x;
NF32 y;
};
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
typedef NimStringV2 tyArray__nHXaesL0DJZHyVS07ARPRA[1];
N_LIB_PRIVATE N_NIMCALL(void, foo__temp_u7)(tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA v_p0);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___temp_u22)(NF32 x_p0);
N_LIB_PRIVATE N_NIMCALL(void, echoBinSafe)(NimStringV2* args_p0, NI args_p0Len_0);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4607)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE NIM_CONST tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA f__temp_u32 = {1.0f, 2.0f}
;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389;
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
NIM_BOOL* result;
result = (NIM_BOOL*)0;
result = (&nimInErrorMode__system_u4389);
return result;
}
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
{
if (!(framePtr__system_u4006 == ((TFrame*) NIM_NIL))) goto LA3_;
(*s_p0).calldepth = ((NI16)0);
}
goto LA1_;
LA3_: ;
{
(*s_p0).calldepth = (NI16)((*framePtr__system_u4006).calldepth + ((NI16)1));
}
LA1_: ;
(*s_p0).prev = framePtr__system_u4006;
framePtr__system_u4006 = s_p0;
{
if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
callDepthLimitReached__system_u4607();
}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
framePtr__system_u4006 = (*framePtr__system_u4006).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, foo__temp_u7)(tyObject_GVec2__66rX5Mweh9bms7DbKC4I0jA v_p0) {
NimStringV2 colontmpD_;
tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL* nimErr_;
nimfr_("foo", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
colontmpD_ = dollar___temp_u22(v_p0.x);
if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
T2_[0] = colontmpD_;
echoBinSafe(T2_, 1);
{
LA1_:;
}
{
if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) {
deallocShared(colontmpD_.p);
}
}
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
}BeforeRet_: ;
popFrame();
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
void (*volatile inner)(void);
inner = PreMainInner;
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
(*inner)();
#else
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot0atslibatssystemdotnim_Init000();
PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
void (*volatile inner)(void);
PreMain();
inner = NimMainInner;
(*inner)();
#else
PreMain();
NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
cmdLine = args;
cmdCount = argc;
gEnv = env;
NimMain();
return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
NIM_BOOL* nimErr_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
foo__temp_u7(f__temp_u32);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
BeforeRet_: ;
nimTestErrorFlag();
popFrame();
}
}
```
2024-11-07T18:08:01
2024-11-07T18:08:02
96.53 Kb (98,848 bytes)
```cpp
#include "nimbase.h"
#include 2024-11-07T18:08:05
2024-11-07T18:08:05
96.52 Kb (98,832 bytes)
```cpp
#include "nimbase.h"
#include 2024-11-07T18:08:08
2024-11-07T18:08:09
92.24 Kb (94,456 bytes)
```cpp
#include "nimbase.h"
#include 2024-11-07T18:08:11
2024-11-07T18:08:12
91.68 Kb (93,880 bytes)
```cpp
#include "nimbase.h"
#include 2024-11-07T18:08:15
2024-11-07T18:08:15
11.4.0
14.0.0
20.4
2024-11-07T18:07:15Z
3
nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
:robot: Bug found in 9 mins
bisecting 1039
commits at 109
commits per second
Of course it doesn't work
Culprit is #23978
Description
This works on Nim 2.0.8 but breaks on 2.0.10:
Nim 2.0.8:
Nim 2.0.10:
Nim Version
Nim Compiler Version 2.0.10 [Linux: amd64] Compiled at 2024-10-01 Copyright (c) 2006-2023 by Andreas Rumpf
git hash: e941ee15be775fe3c46db1bed9b4f41c7dfb1334 active boot switches: -d:relea
Current Output
No response
Expected Output
No response
Known Workarounds
No response
Additional Information
No response