Open fierce-goose opened 2 months ago
!nim c
proc `++`(n: var int) = n += 1
type r = range[0..15]
var a: r = 15
++a
echo a
93.14 Kb (95,376 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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
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, plusplus___temp_u1)(NI* n_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4613)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___systemZdollars_u8)(NI 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);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE NI a__temp_u8 = ((NI)15);
extern NIM_THREADVAR TFrame* framePtr__system_u2654;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4397;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
{
if (!(framePtr__system_u2654 == ((TFrame*) NIM_NIL))) goto LA3_;
(*s_p0).calldepth = ((NI16)0);
}
goto LA1_;
LA3_: ;
{
(*s_p0).calldepth = (NI16)((*framePtr__system_u2654).calldepth + ((NI16)1));
}
LA1_: ;
(*s_p0).prev = framePtr__system_u2654;
framePtr__system_u2654 = s_p0;
{
if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
callDepthLimitReached__system_u4613();
}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
framePtr__system_u2654 = (*framePtr__system_u2654).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, plusplus___temp_u1)(NI* n_p0) {
NI TM__SRd76hP9cMfCzdUO857UhQQ_2;
nimfr_("++", "/home/runner/work/Nim/Nim/temp.nim");
{ if (nimAddInt((*n_p0), ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_2)) { raiseOverflow(); goto BeforeRet_;
};
(*n_p0) = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_2);
}BeforeRet_: ;
popFrame();
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
NIM_BOOL* result;
result = (&nimInErrorMode__system_u4397);
return result;
}
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;
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_Init000();
(*inner)();
#else
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminusathdevelatslibatssystemdotnim_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) {
{
NimStringV2 colontmpD_;
tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL* nimErr_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
plusplus___temp_u1(((NI*) ((&a__temp_u8))));
if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
colontmpD_ = dollar___systemZdollars_u8(((NI) (a__temp_u8)));
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_: ;
nimTestErrorFlag();
popFrame();
}
}
```
2024-08-29T22:16:58
2024-08-29T22:16:59
93.10 Kb (95,336 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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
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, plusplus___temp_u1)(NI* n_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4620)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___systemZdollars_u8)(NI 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);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot8atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE NI a__temp_u8 = ((NI)15);
extern NIM_THREADVAR TFrame* framePtr__system_u4059;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4402;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
{
if (!(framePtr__system_u4059 == ((TFrame*) NIM_NIL))) goto LA3_;
(*s_p0).calldepth = ((NI16)0);
}
goto LA1_;
LA3_: ;
{
(*s_p0).calldepth = (NI16)((*framePtr__system_u4059).calldepth + ((NI16)1));
}
LA1_: ;
(*s_p0).prev = framePtr__system_u4059;
framePtr__system_u4059 = s_p0;
{
if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
callDepthLimitReached__system_u4620();
}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
framePtr__system_u4059 = (*framePtr__system_u4059).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, plusplus___temp_u1)(NI* n_p0) {
NI TM__SRd76hP9cMfCzdUO857UhQQ_2;
nimfr_("++", "/home/runner/work/Nim/Nim/temp.nim");
{ if (nimAddInt((*n_p0), ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_2)) { raiseOverflow(); goto BeforeRet_;
};
(*n_p0) = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_2);
}BeforeRet_: ;
popFrame();
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
NIM_BOOL* result;
result = (&nimInErrorMode__system_u4402);
return result;
}
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;
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot8atslibatssystemdotnim_Init000();
(*inner)();
#else
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot8atslibatssystemdotnim_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) {
{
NimStringV2 colontmpD_;
tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL* nimErr_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
plusplus___temp_u1((&a__temp_u8));
if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
colontmpD_ = dollar___systemZdollars_u8(((NI) (a__temp_u8)));
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_: ;
nimTestErrorFlag();
popFrame();
}
}
```
2024-08-29T22:17:03
2024-08-29T22:17:03
93.10 Kb (95,336 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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
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, plusplus___temp_u1)(NI* n_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
static N_INLINE(void, nimFrame)(TFrame* s_p0);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__system_u4620)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(NimStringV2, dollar___systemZdollars_u8)(NI 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);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot8atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE NI a__temp_u8 = ((NI)15);
extern NIM_THREADVAR TFrame* framePtr__system_u4059;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4402;
static N_INLINE(void, nimFrame)(TFrame* s_p0) {
{
if (!(framePtr__system_u4059 == ((TFrame*) NIM_NIL))) goto LA3_;
(*s_p0).calldepth = ((NI16)0);
}
goto LA1_;
LA3_: ;
{
(*s_p0).calldepth = (NI16)((*framePtr__system_u4059).calldepth + ((NI16)1));
}
LA1_: ;
(*s_p0).prev = framePtr__system_u4059;
framePtr__system_u4059 = s_p0;
{
if (!((*s_p0).calldepth == ((NI16)2000))) goto LA8_;
callDepthLimitReached__system_u4620();
}
LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
framePtr__system_u4059 = (*framePtr__system_u4059).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, plusplus___temp_u1)(NI* n_p0) {
NI TM__SRd76hP9cMfCzdUO857UhQQ_2;
nimfr_("++", "/home/runner/work/Nim/Nim/temp.nim");
{ if (nimAddInt((*n_p0), ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_2)) { raiseOverflow(); goto BeforeRet_;
};
(*n_p0) = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_2);
}BeforeRet_: ;
popFrame();
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
NIM_BOOL* result;
result = (&nimInErrorMode__system_u4402);
return result;
}
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;
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot8atslibatssystemdotnim_Init000();
(*inner)();
#else
atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot8atslibatssystemdotnim_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) {
{
NimStringV2 colontmpD_;
tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL* nimErr_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
plusplus___temp_u1((&a__temp_u8));
if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
colontmpD_ = dollar___systemZdollars_u8(((NI) (a__temp_u8)));
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_: ;
nimTestErrorFlag();
popFrame();
}
}
```
2024-08-29T22:17:03
2024-08-29T22:17:04
90.96 Kb (93,144 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 NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
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, plusplus___temp_u1)(NI* n_p0);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(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(NimStringV2, dollar___systemZdollars_u8)(NI 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);
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 NI a__temp_u8 = ((NI)15);
extern NIM_THREADVAR TFrame* framePtr__system_u4006;
extern NIM_THREADVAR NIM_BOOL nimInErrorMode__system_u4389;
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, plusplus___temp_u1)(NI* n_p0) {
NI TM__SRd76hP9cMfCzdUO857UhQQ_2;
nimfr_("++", "/home/runner/work/Nim/Nim/temp.nim");
{ if (nimAddInt((*n_p0), ((NI)1), &TM__SRd76hP9cMfCzdUO857UhQQ_2)) { raiseOverflow(); goto BeforeRet_;
};
(*n_p0) = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_2);
}BeforeRet_: ;
popFrame();
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
NIM_BOOL* result;
result = (NIM_BOOL*)0;
result = (&nimInErrorMode__system_u4389);
return result;
}
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) {
{
NimStringV2 colontmpD_;
tyArray__nHXaesL0DJZHyVS07ARPRA T2_;
NIM_BOOL* nimErr_;
nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
plusplus___temp_u1((&a__temp_u8));
if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
colontmpD_ = dollar___systemZdollars_u8(((NI) (a__temp_u8)));
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_: ;
nimTestErrorFlag();
popFrame();
}
}
```
2024-08-29T22:17:07
2024-08-29T22:17:07
96.01 Kb (98,312 bytes)
```cpp
#include "nimbase.h"
#include 2024-08-29T22:17:10
2024-08-29T22:17:10
92.11 Kb (94,320 bytes)
```cpp
#include "nimbase.h"
#include 2024-08-29T22:17:12
2024-08-29T22:17:13
91.84 Kb (94,040 bytes)
```cpp
#include "nimbase.h"
#include 2024-08-29T22:17:15
2024-08-29T22:17:15
86.98 Kb (89,064 bytes)
```cpp
#include "nimbase.h"
#include 2024-08-29T22:17:16
2024-08-29T22:17:17
11.4.0
14.0.0
20.4
2024-08-29T22:16:30Z
1
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 21 mins
bisecting 8
commits at 0
commits per second
The issue is that range
implicitly converted to var int
as such it loses range checking. A work around is to use
proc `++`[T: range | SomeInteger](n: var T) =
n = n + 1
type
r = range[ 0..15 ]
var a: r = 15
++a
echo a
That should be in the documentation.
range int
should not convert to var int
.
Seems like a typo in the compiler
subtypeCheck
is only called for pointer types, but it also checks if the element type of the pointer type (f.last
) is a pointer type which I don't think is intentional
I know changing this breaks a package though (from #23176) so we need to at least give a error message that suggests doing ++int(a)
instead ("explicit conversion needed" etc), but also we can only do this for isSubrange
Actually some subtype relations for var
are allowed, like openarray
and non-ref object subtypes:
type
Foo = object of RootObj
Bar = object of Foo
proc foo(x: var Foo) = echo "a"
var x: Bar
foo(x) # a
This is intentional: https://github.com/nim-lang/Nim/commit/f348671ba7146420e1bfc7cd21ddc5464f0b9cb3
But still isIntConv
etc should fail. So I'm guessing only subtypes should be special cased to have this behavior.
Edit: Never mind the openarray
relation is isConvertible
. But still valid so just another special case.
Also ++int(a)
doesn't work
yes, it means "isSubrange" is a different type relation from "isSubtype". (I wasn't aware of this until now :-) )
Description
this code should have thrown an error because I'm trying to assign a variable a value larger than possible, but it just goes beyond the allowed limits without error
Nim Version
Nim Compiler Version 2.0.8 [Linux: amd64]
Current Output
Expected Output
Known Workarounds
No response
Additional Information
No response