├── tests ├── dll │ ├── nimhcr_1.nim │ ├── nimhcr_2.nim │ ├── nimhcr_1_3.nim │ ├── nimhcr_2_3.nim │ ├── client.nim.cfg │ ├── server.nim.cfg │ ├── nimhcr_unit.nim.cfg │ ├── nimhcr_0_5.nim │ ├── nimhcr_1_2.nim │ ├── nimhcr_0.nim │ ├── nimhcr_0_6.nim │ ├── nimhcr_2_2.nim │ └── nimhcr_basic.nim ├── stdlib │ ├── tdb.nim │ ├── tdb_mysql.nim │ ├── tsqlitebindatas.nim │ ├── tdb.nims │ ├── ttypeinfo.nims │ ├── tbitops.nim.cfg │ ├── t9754.nim │ ├── tjsontestsuite.nim │ ├── nre │ │ ├── optional_nonstrict.nim │ │ └── escape.nim │ ├── mstrscans_undecl_scanf.nim │ ├── tstrscans_undecl_scanf.nim │ ├── t21251.nim │ ├── osproctest.nim │ ├── toserrors.nim │ ├── tterminal.nim │ ├── tintsets.nim │ ├── tterminal_15874.nim │ ├── t15663.nim │ ├── t21406.nim │ ├── tstrtabs.nims │ ├── t7686.nim │ ├── tfenv.nim │ ├── tmemlines.nim │ ├── mjsonexternproc.nim │ ├── tjsonexternproc.nim │ └── tstrformatlineinfo.nim ├── js │ ├── t21209.nims │ ├── tjsnimscombined.nim │ ├── tdiscard.nim │ ├── t8231.nim │ ├── tfloatround.nim │ ├── t7127.nim │ ├── tjsnimscombined.nims │ ├── t11697.nim │ ├── tcsymbol.nim │ ├── testtojsstr.nim │ ├── t20233.nim │ ├── temptyseq.nim │ ├── t21209.nim │ ├── t7534.nim │ ├── tmodify_cstring.nim │ ├── t14570.nim │ ├── t8821.nim │ ├── t7109.nim │ ├── t8914.nim │ ├── tunion.nim │ ├── t20235.nim │ ├── t11353.nim │ ├── tjshello_stacktrace.nim │ ├── t12672.nim │ ├── t21439.nim │ ├── tcodegendeclvar.nim │ └── testmagic.nim ├── newconfig │ ├── bar │ │ ├── mfoo.nim │ │ ├── nim.cfg │ │ ├── config.nims │ │ ├── mfoo.nim.cfg │ │ └── mfoo.nims │ ├── foo2 │ │ └── mfoo2.customext │ ├── mymath.nim │ └── mconfigcheck.nims ├── import_in_config │ ├── other.nim │ ├── tmain.nim │ └── nim.cfg ├── misc │ ├── m20456.nims │ ├── m15316.nim │ ├── m20149.nim │ ├── modulea.nim │ ├── t16264.nim │ ├── tmodulea.nim │ ├── 99bottles.nim │ ├── tparedef.nim │ ├── t12480.nim │ ├── t15351.nim │ ├── minit.nim │ ├── t9710.nim │ ├── mvarious.nim │ ├── m15955.nim │ ├── mbetterrun.nim │ ├── t23240.nim │ ├── t6549.nim │ ├── tsamename2.nim │ ├── t21443.nim │ ├── tcharinc.nim │ ├── tnolen.nim │ ├── tjoinable.nim │ ├── tfib.nim │ ├── t16244.nim │ ├── tvcc.nim │ ├── t3907.nim │ ├── t20253.nim │ └── åäö.nim ├── arc │ ├── testfile.txt │ ├── bmodule.nim │ ├── nim.cfg │ ├── t14864.nim │ ├── cmodule.nim │ ├── t16458.nim │ ├── t20456.nim │ ├── tamodule.nim │ ├── tinvalidenumtostr.nim │ ├── t18971.nim │ ├── t17173.nim │ ├── m24764.nim │ ├── t16033.nim │ └── t16558.nim ├── async │ ├── hello.txt │ ├── nim.cfg │ ├── tioselectors.nim.cfg │ ├── t21447.nim │ ├── ttemplateinasync.nim │ └── tasync_nofuture.nim ├── compiles │ ├── mstaticlib.nim │ └── t8630.nim ├── ic │ ├── config.nims │ ├── mdefconverter.nim │ ├── mimportsb.nim │ ├── mbaseobj.nim │ └── mimports.nim ├── package │ ├── stdlib │ │ ├── stdlib.nimble │ │ └── system.nim │ └── tstdlib_name_not_special.nim ├── threads │ ├── nim.cfg │ └── tjsthreads.nim ├── untestable │ └── tpostgres.nim ├── vm │ ├── tgorge.bat │ ├── tgorge.sh │ ├── tgorgeex.bat │ ├── tgorgeex.sh │ ├── tconst_float_as_int.nim │ ├── tcgemptycallarg.nim │ ├── mscriptcompiletime.nim │ ├── tconstscope1.nim │ ├── tnilref.nim │ ├── t19199.nim │ ├── tconstscope2.nim │ ├── tnilclosurecall.nim │ ├── tscriptcompiletime.nims │ ├── tconststaticvar_wrong.nim │ ├── tunsupportedintfloatcast.nim │ ├── tconststaticvar3.nim │ ├── t17039.nim │ ├── tconststaticvar2.nim │ ├── tnocompiletimefunclambda.nim │ ├── tclosureiterator.nim │ ├── toverflowopcsubimmint.nim │ ├── twrongconst.nim │ ├── toverflowopcaddimmint.nim │ ├── toverflowopcmulint.nim │ ├── tvarsection.nim │ ├── toverflowopcaddint.nim │ └── toverflowopcsubint.nim ├── dummy.txt ├── gc │ ├── gctest.nim.cfg │ └── tdisable_orc.nim ├── manyloc │ ├── packages │ │ ├── package1 │ │ │ ├── p1.babel │ │ │ └── strutils.nim │ │ ├── package2 │ │ │ ├── p2.babel │ │ │ └── strutils.nim │ │ ├── noconflicts.nim.cfg │ │ └── os.nim │ ├── nake │ │ └── nakefile.nim.cfg │ ├── standalone │ │ └── barebone.nim.cfg │ ├── keineschweine │ │ ├── dependencies │ │ │ └── sfml │ │ │ │ └── sfml_vector.nim │ │ └── server │ │ │ ├── nim.cfg │ │ │ └── dirserver_settings.json │ ├── argument_parser │ │ └── ex_wget.nim.cfg │ ├── standalone2 │ │ ├── tavr.nim.cfg │ │ └── tavr.nim │ └── named_argument_bug │ │ ├── main.nim.cfg │ │ └── tri_engine │ │ ├── config.nim │ │ └── math │ │ ├── circle.nim │ │ └── rect.nim ├── modules │ ├── m9627 │ │ ├── a.nim │ │ └── b.nim │ ├── mrecmod.nim │ ├── mincludeprefix.nim │ ├── mnamspc1.nim │ ├── mincludetemplate.nim │ ├── mnotuniquename.nim │ ├── morder_depb.nim │ ├── a │ │ ├── utils.nim │ │ └── module_name_clashes.nim │ ├── b │ │ ├── utils.nim │ │ └── module_name_clashes.nim │ ├── mimport_in_config.nim │ ├── mnamspc2.nim │ ├── proxy_module.nim │ ├── tnotuniquename_dir │ │ └── mnotuniquename.nim │ ├── seq.nim │ ├── t8665.nim │ ├── timport_in_config.nim.cfg │ ├── mexport2b.nim │ ├── mforwarded_pure_enum2.nim │ ├── mrange.nim │ ├── morder_depa.nim │ ├── tutils_ab.nim │ ├── UpperCased.nim │ ├── mmodule_same_proc_client.nim │ ├── mforwarded_pure_enum.nim │ ├── t9627.nim │ ├── tseq.nim │ ├── definitions.nim │ ├── tincludeprefix.nim │ ├── tfowarded_pure_enum.nim │ ├── tincludeas.nim │ ├── mexport2a.nim │ ├── mexportb.nim │ ├── tuppercased.nim │ ├── mopaque.nim │ ├── torder_dep.nim │ ├── mexporta.nim │ ├── texplicit_system_import.nim │ ├── timport_in_config.nim │ ├── tincludetemplate.nim │ ├── tmodule_same_proc.nim │ ├── timportexcept.nim │ ├── trecmod.nim │ ├── tnotuniquename.nim │ ├── mmodule_same_proc.nim │ ├── trecinca.nim │ └── trecincb.nim ├── msgs │ ├── mused2c.nim │ ├── mused2b.nim │ ├── thints_off.nim │ └── mspellsuggest.nim ├── compilerapi │ ├── invalid.nim │ └── exposed.nim ├── destructor │ ├── nim.cfg │ ├── helper.nim │ ├── t25341_aux │ │ ├── a.nim │ │ └── b.nim │ ├── tconst_smart_ptr.nim │ ├── t25341.nim │ ├── objFile.nim │ ├── tglobaldestructor.nim │ └── tgotoexceptions3.nim ├── errmsgs │ ├── mambtype1.nim │ ├── mambtype2.nim │ ├── mambparam1.nim │ ├── mambparam3.nim │ ├── mb.nim │ ├── m8794.nim │ ├── mc.nim │ ├── mambparam2.nim │ ├── t23060.nim │ ├── tstaticexprnotype.nim │ ├── t18327.nim │ ├── t5282.nim │ ├── t18983.nim │ ├── t8610.nim │ ├── ttupleindexoutofbounds.nim │ ├── tassignunpack.nim │ ├── temptysetparam.nim │ ├── t10594.nim │ ├── t23419.nim │ ├── t6499.nim │ ├── t22996.nim │ ├── tkeywordparam.nim │ ├── tuncheckedarrayvar.nim │ ├── t25120.nim │ ├── tconsttypemismatch.nim │ ├── t22097.nim │ ├── tnnodeindex.nim │ ├── t8339.nim │ ├── t19882_2.nim │ ├── tnnodeadd.nim │ ├── trecursiveproctype3.nim │ ├── twrongdefinetype.nim │ ├── tcannot_capture_builtin.nim │ ├── trecursiveproctype6.nim │ ├── t8064.nim │ ├── ta.nim │ ├── tconstinfo.nim │ ├── tnnodeindexkind.nim │ ├── tcant_overload_by_return_type.nim │ ├── tmultiple_finally.nim │ ├── t6281.nim │ ├── t9908_01.nim │ ├── tgeneral_excepts.nim │ ├── tnested_empty_seq.nim │ ├── t22852.nim │ ├── t23355.nim │ ├── trecursiveproctype4.nim │ ├── t9908_02.nim │ └── tnoop.nim ├── lookups │ ├── mambtype1.nim │ ├── mdisambsym2.nim │ ├── mdisambsym3.nim │ ├── mambsym2.nim │ ├── mdisambsym1.nim │ ├── issue_23032 │ │ └── deep_scope.nim │ ├── mambsym4.nim │ ├── mambsym3.nim │ ├── mambsys2.nim │ ├── issue_23172 │ │ └── m23172.nim │ ├── mambsys1.nim │ ├── mbind3.nim │ ├── tdisambsym.nim │ ├── tmoduleclash2.nim │ ├── mambtype2.nim │ ├── t23172.nim │ ├── tmacroamb.nim │ ├── tambsys.nim │ └── mambsym1.nim ├── nimdoc │ ├── imp.nim │ ├── sub │ │ ├── imp.nim │ │ ├── imp2.nim │ │ └── mmain.nim │ └── readme.md ├── package_level_objects │ ├── mypackage.nimble │ └── definefoo.nim ├── assert │ ├── config.nims │ ├── tunittests.nim │ └── t21195.nim ├── compiler │ ├── tcmdlinecpuamd64.nim.cfg │ ├── tcmdlineoswin.nim.cfg │ ├── tcmdlineclib.nim │ ├── samplelib.nim │ ├── tgrammar.nim │ └── t12684.nim ├── coroutines │ ├── tgc.nim.cfg │ ├── twait.nim.cfg │ ├── texceptions.nim.cfg │ └── titerators.nim.cfg ├── niminaction │ ├── Chapter3 │ │ ├── various3.nim.cfg │ │ └── ChatApp │ │ │ └── src │ │ │ └── client.nim.cfg │ ├── Chapter6 │ │ └── WikipediaStats │ │ │ ├── concurrency.nim.cfg │ │ │ ├── parallel_counts.nim.cfg │ │ │ ├── race_condition.nim.cfg │ │ │ ├── unguarded_access.nim.cfg │ │ │ └── concurrency_regex.nim.cfg │ ├── Chapter7 │ │ └── Tweeter │ │ │ └── tests │ │ │ └── database_test.nims │ └── Chapter2 │ │ ├── no_iterator.nim │ │ ├── no_seq_type.nim │ │ └── explicit_discard.nim ├── pragmas │ ├── monoff1.nim │ ├── cfunction.c │ ├── foobar.nim │ ├── tuserpragma.nim │ ├── warn_module.nim │ ├── tonoff1.nim │ ├── tcompile_missing_file.nim │ ├── t4384.nim │ ├── tpushexperimental.nim │ ├── tsym_as_pragma.nim │ ├── tuserpragmaargs.nim │ ├── t13306.nim │ ├── tpragmablock.nim │ └── tcompile_pragma.nim ├── constructors │ ├── a.nim │ ├── b.nim │ ├── t18990.nim │ ├── t5965_2.nim │ └── t5965_1.nim ├── import │ ├── buzz │ │ └── m21496.nim │ ├── fizz │ │ └── m21496.nim │ ├── t22065.nim │ ├── t23167.nim │ ├── t22208.nim │ └── t21496.nim ├── nimble │ ├── nimbleDir │ │ ├── simplePkgs │ │ │ ├── pkgA-0.1.0 │ │ │ │ ├── pkgA.nimble │ │ │ │ └── pkgA │ │ │ │ │ └── module.nim │ │ │ ├── pkgB-#head │ │ │ │ ├── pkgB.nimble │ │ │ │ └── pkgB │ │ │ │ │ └── module.nim │ │ │ ├── pkgB-0.1.0 │ │ │ │ ├── pkgB.nimble │ │ │ │ └── pkgB │ │ │ │ │ └── module.nim │ │ │ ├── pkgC-#aa11 │ │ │ │ ├── pkgC.nimble │ │ │ │ └── pkgC │ │ │ │ │ └── module.nim │ │ │ └── pkgC-#head │ │ │ │ ├── pkgC.nimble │ │ │ │ └── pkgC │ │ │ │ └── module.nim │ │ └── linkedPkgs │ │ │ ├── pkgA-0.1.0 │ │ │ └── pkgA.nimble-link │ │ │ ├── pkgB-#head │ │ │ └── pkgB.nimble-link │ │ │ └── pkgB-0.1.0 │ │ │ └── pkgB.nimble-link │ └── readme.md ├── parallel │ ├── nim.cfg │ ├── t9691.nim │ └── tsysspawnbadarg.nim ├── template │ ├── m1027a.nim │ ├── m1027b.nim │ ├── i2416.nim │ ├── mqualifiedtype1.nim │ ├── m19277_1.nim │ ├── m19277_2.nim │ ├── mqualifiedtype2.nim │ ├── mlt.nim │ ├── tsighash_regression.nim │ ├── tfielduse.nim │ ├── t21532.nim │ ├── mcan_access_hidden_field.nim │ ├── mdotcall2.nim │ ├── t21231.nim │ ├── tparamscope.nim │ ├── template_pragmas.nim │ └── tqualifiedident.nim ├── tools │ ├── compile │ │ ├── config.nims │ │ ├── readme.md │ │ ├── tkoch.nim │ │ ├── tdeps.nim │ │ ├── tniminst.nim │ │ └── tdetect.nim │ ├── tloadstdin.nims │ ├── second.nim │ ├── dontmentionme.nim │ ├── config.nims │ └── tctags2.nim ├── cpp │ ├── fam.h │ ├── enum.hpp │ ├── foo.c │ ├── tnativesockets.nim │ ├── ttypeinfo2.nim │ ├── t12946.nim │ ├── tfam.nim │ ├── tembarrassing_generic_bug.nim │ ├── t23306.nim │ ├── virtualptr.nim │ ├── tgen_prototype_for_importc.nim │ └── tenum_set.nim ├── navigator │ └── minclude.nim ├── exception │ ├── m21261.nim │ ├── m22469.nim │ ├── t20613.nim │ ├── t22008.nim │ ├── t21261.nim │ └── twrongexc.nim ├── stylecheck │ ├── foreign_package │ │ ├── foreign_package.nim │ │ └── foreign_package.nimble │ ├── fileinfo.nim │ ├── t20397.nim │ ├── t20397_2.nim │ └── t20397_1.nim ├── c │ ├── tcompile.c │ ├── timportedsize.nim │ └── tcompile.nim ├── sandwich │ ├── config.nims │ ├── tsetin.nim │ ├── helper_module.nim │ ├── mdollar3.nim │ ├── msetiter2.nim │ ├── mdollar1.nim │ ├── generic_library.nim │ ├── tmain.nim │ ├── tstatic.nim │ ├── tfilehandles.nim │ ├── msetiter1.nim │ ├── mdollar2.nim │ ├── tsetiter2.nim │ └── mstatic.nim ├── system │ ├── helpers │ │ └── readall_echo.nim │ ├── temptyecho.nim │ ├── tnewderef.nim │ ├── tgcnone.nim │ ├── tgogc.nim │ ├── tslimsystem.nim │ ├── timmutableinc.nim │ ├── treprconverter.nim │ ├── tatomics1.nim │ ├── tgcregions.nim │ ├── tcopyprotected_arrayinit.nim │ └── t20938.nim ├── ccgbugs │ ├── m19445.c │ ├── t8616.nim │ ├── m1 │ │ └── defs.nim │ ├── m2 │ │ └── defs.nim │ ├── pkg8616 │ │ ├── rtarray.nim │ │ └── scheduler.nim │ ├── t20787.nim │ ├── xoa9578.nim │ ├── t21995.nim │ ├── tuplecast.nim │ ├── xseq9578.nim │ ├── thtiobj.nim │ ├── tsequence_outoforder.nim │ ├── mstatic_assert.nim │ ├── xarray9578.nim │ ├── tcompile_time_var_at_runtime.nim │ ├── t10964.nim │ ├── t7079.nim │ ├── t19585.nim │ ├── t5345.nim │ ├── tcodegenbug_bool.nim │ ├── topenarraycast.nim │ ├── xua9578.nim │ ├── t21116.nim │ ├── xtuple9578.nim │ ├── tborrowmagic.nim │ ├── tweakopenarray.nim │ └── t9098.nim ├── dir with space │ └── more spaces │ │ └── mspace.nim ├── importalls │ ├── m2.nim │ ├── mt4b.nim │ ├── mt4.nim │ ├── m3.nim │ ├── m4.nim │ └── mt0.nim ├── macros │ ├── mparsefile.nim │ ├── t14329.nim │ ├── tsame_name_497.nim │ ├── t7454.nim │ ├── tmacroaspragma.nim │ ├── t15751.nim │ ├── t21593.nim │ └── treturnsempty.nim ├── sets │ ├── t17385.nim │ ├── t2669.nim │ ├── tnewsets.nim │ └── t13764.nim ├── concepts │ ├── t5888lib │ │ ├── ca.nim │ │ └── opt.nim │ ├── t20237.nim │ ├── ttrieconcept.nim │ ├── tvarconcept.nim │ └── conceptsv2_helper.nim ├── enum │ ├── m16462_1.nim │ ├── m16462_2.nim │ ├── t16462.nim │ ├── mcrossmodule.nim │ ├── tenumitems.nim │ ├── tenum_invalid.nim │ ├── toverloadedname.nim │ ├── tenum_duplicate.nim │ ├── tenum_self.nim │ ├── tenummix.nim │ └── tenumfieldpragmanoannot.nim ├── objects │ ├── mobjconstr_msgs.nim │ ├── tillegal_recursion2.nim │ ├── tillegal_recursion3.nim │ ├── trefobjfieldoverload.nim │ ├── tillegal_recursion.nim │ └── tunsafenew.nim ├── generics │ ├── mmodule_same_as_proc.nim │ ├── mpragma1.nim │ ├── topensymimport.nim │ ├── t14509.nim │ ├── mpragma2.nim │ ├── taliashijack.nim │ ├── t18823.nim │ ├── t8270.nim │ ├── m22373a.nim │ ├── t500.nim │ ├── tpragma.nim │ ├── mtypenodes.nim │ ├── t21760.nim │ ├── t22826.nim │ ├── tbadgenericlambda.nim │ ├── t21742.nim │ ├── t7141.nim │ ├── mfriends.nim │ ├── t14193.nim │ ├── tgenericbodyreturn1.nim │ ├── t1500.nim │ ├── m3770.nim │ ├── t7446.nim │ ├── twrongdotcallcrash.nim │ └── tfriends.nim ├── rectest.nim ├── tuples │ ├── twrong_generic_caching.nim │ ├── mnimsconstunpack.nim │ ├── ttypedesc_in_tuple_a.nim │ ├── ttypedesc_in_tuple_b.nim │ ├── tnimsconstunpack.nim │ ├── t7012.nim │ └── twrongtupleaccess.nim ├── converter │ ├── m18986.nim │ ├── mdontleak.nim │ ├── tconvcolors.nim │ ├── tvargenericconverter.nim │ ├── tdontleak.nim │ ├── t18986.nim │ └── tconverter.nim ├── parser │ ├── t19430.nim │ ├── tbinarynotindented.nim │ ├── t19662.nim │ ├── tdoublenotnil.nim │ ├── twrongcmdsyntax.nim │ ├── ttypecommandcomma.nim │ ├── tifextracolon.nim │ ├── tifexprs.nim │ ├── tstmtlistexprindent.nim │ ├── ttypecommandindent1.nim │ ├── tbinarynotsameline.nim │ ├── t12274.nim │ ├── tinvifstmt.nim │ ├── tstatementoperators.nim │ ├── ttypecommandindent2.nim │ └── ttypecommandindent3.nim ├── proc │ ├── mdefaultprocparam.nim │ ├── msugarcrash1.nim │ ├── typed.nim │ ├── tlambdapragma.nim │ ├── t17157.nim │ └── tprocredef.nim ├── testdata │ ├── jsonwithextradata.json │ ├── data.csv │ └── csvtest.csv ├── typerel │ ├── tuncheckedarray_eq.nim │ ├── ttypedesc_as_genericparam1_orc.nim │ ├── t8905.nim │ ├── tsigmatch.nim │ ├── ttypelessemptyset.nim │ ├── tno_int_in_bool_context.nim │ ├── tptrs.nim │ ├── ttypedesc_as_genericparam1.nim │ ├── typredef.nim │ ├── ttynilinstantiation.nim │ └── ttypedesc_as_genericparam2.nim ├── types │ ├── ttypeofobjconstr.nim │ ├── t6969.nim │ ├── told_pragma_syntax1.nim │ ├── told_pragma_syntax2.nim │ ├── t6456.nim │ ├── tforwty.nim │ ├── tnontype.nim │ ├── tillegalseqrecursion.nim │ ├── t21027.nim │ ├── texportgeneric.nim │ ├── tinfiniterecursion.nim │ ├── tillegaltuplerecursiongeneric2.nim │ ├── tillegaltuplerecursiongeneric.nim │ ├── tillegaltyperecursion2.nim │ └── tillegaltyperecursion3.nim ├── global │ ├── globalaux2.nim │ ├── a_module.nim │ ├── t5958.nim │ ├── tglobal2.nim │ ├── t21896.nim │ └── tglobalforvar.nim ├── exprs │ ├── thighCString.nim │ ├── tstmtexp.nim │ └── tresultwarning.nim ├── init │ └── tlet_uninit2.nim ├── statictypes │ └── t5780.nim ├── casestmt │ ├── tcase_issues.nim │ └── trangeexhaustiveness.nim ├── overload │ ├── importA.nim │ ├── t7416.nim │ ├── tambiguousexplicitgeneric.nim │ ├── tissue966.nim │ └── texplicitgenericdiscard.nim ├── align │ ├── globalalignas.nim │ └── tillegalalign.nim ├── valgrind │ └── tbasic_valgrind.nim ├── range │ └── compilehelpers.nim ├── iter │ ├── titerslice.nim │ ├── ttypeofclosureiter.nim │ ├── titerautoerr3.nim │ ├── titerautoerr1.nim │ ├── titerautoerr2.nim │ └── tsubscript.nim ├── lexer │ ├── tinvalidintegerliteral1.nim │ ├── tinvalidintegerliteral2.nim │ ├── tinvalidintegerliteral3.nim │ └── tmissingnl.nim ├── array │ ├── tidx_lit_err2.nim │ ├── tidx_lit_err3.nim │ ├── tindexconv.nim │ ├── tgenericindex.nim │ └── tidx_lit_err1.nim ├── int │ └── twrongvarconv.nim ├── testament │ ├── t16576.nim │ └── treject.nim ├── views │ └── tcan_compile_nim.nim ├── metatype │ └── typedesc_as_value.nim ├── stmt │ ├── tforloop_underscore.nim │ └── tgenericsunderscore.nim ├── refc │ ├── t24844.nim │ └── m24844.nim ├── discard │ └── tillegaldiscard.nim ├── overflow │ ├── tdistinct_range.nim │ ├── twronginference.nim │ └── toverflow2.nim ├── avr │ └── thello.nim ├── closure │ ├── tinvalidclosure4.nim │ └── t15594.nim ├── defer │ └── t22309.nim ├── method │ └── tmethod.nim ├── openarray │ ├── t8259.nim │ └── topena1.nim ├── stckovfl.nim ├── let │ └── timportc2.nim ├── benchmarks │ └── readme.md ├── showoff │ └── thtml1.nim ├── varres │ └── tvarres3.nim └── effects │ ├── teffects10.nim │ └── tlaxeffects.nim ├── compiler └── plugins │ └── plugins.nimble ├── nimdoc ├── testproject │ └── testproject.nimble ├── extlinks │ ├── util.nim │ └── project │ │ └── expected │ │ └── _._ │ │ └── util.idx └── test_out_index_dot_html │ ├── foo.nim │ └── expected │ └── foo.idx ├── lib ├── pure │ ├── coro.nimcfg │ ├── nimprof.nim.cfg │ ├── concurrency │ │ └── threadpool.nim.cfg │ └── asyncdispatch.nim.cfg ├── nimhcr.nim.cfg ├── impure │ └── nre │ │ └── .gitignore ├── nimrtl.nim.cfg ├── stdlib.nimble ├── system │ └── formatfloat.nim └── deprecated │ └── pure │ └── future.nim ├── tools ├── ssl_config_parser.nims ├── niminst │ ├── setup.ico │ ├── nim-file.ico │ └── uninstall.ico ├── detect │ ├── .gitignore │ └── timesize.c └── start.bat ├── icons ├── koch.rc ├── nim.rc ├── koch.ico ├── koch.res ├── nim.ico ├── nim.res ├── koch_icon.o ├── nim_icon.o ├── nim-i386-windows-vcc.res ├── koch-amd64-windows-vcc.res ├── koch-i386-windows-vcc.res └── nim-amd64-windows-vcc.res ├── nimpretty ├── nimpretty.nim.cfg └── tests │ ├── simple4.nim │ └── expected │ └── simple4.nim ├── nimsuggest ├── tests │ ├── t20440.nims │ ├── fixtures │ │ ├── mdep_v1.nim │ │ ├── mdep_v2.nim │ │ ├── minclude_types.nim │ │ ├── mfakeassert.nim │ │ └── minclude_include.nim │ ├── module_20265.nim │ ├── t20440.nim │ ├── taccent_highlight.nim │ ├── tv3_import.nim │ ├── tdef_let.nim │ ├── timport1.nim │ ├── tsug_recursive.nim │ ├── tv3_definition.nim │ └── t22448.nim └── config.nims ├── bin └── empty.txt ├── testament ├── tests │ └── shouldfail │ │ ├── texitcode1.nim │ │ ├── tmaxcodesize.nim │ │ ├── toutput.nim │ │ ├── toutputsub.nim │ │ ├── ttimeout.nim │ │ ├── tnimout.nim │ │ ├── tfile.nim │ │ ├── tccodecheck.nim │ │ ├── terrormsg.nim │ │ ├── tcolumn.nim │ │ ├── tline.nim │ │ ├── tsortoutput.nim │ │ └── treject.nim └── lib │ └── readme.md ├── config └── rename.rules.cfg ├── koch.nim.cfg └── doc └── overview.md /tests/dll/nimhcr_1.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_2.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/stdlib/tdb.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_1_3.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_2_3.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/js/t21209.nims: -------------------------------------------------------------------------------- 1 | --b:js -------------------------------------------------------------------------------- /tests/newconfig/bar/mfoo.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/newconfig/bar/nim.cfg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/stdlib/tdb_mysql.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compiler/plugins/plugins.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/import_in_config/other.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/import_in_config/tmain.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/misc/m20456.nims: -------------------------------------------------------------------------------- 1 | echo 123 -------------------------------------------------------------------------------- /tests/newconfig/bar/config.nims: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/newconfig/bar/mfoo.nim.cfg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/newconfig/bar/mfoo.nims: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/stdlib/tsqlitebindatas.nim: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nimdoc/testproject/testproject.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/arc/testfile.txt: -------------------------------------------------------------------------------- 1 | 1 x 2 | 2 y 3 | -------------------------------------------------------------------------------- /tests/async/hello.txt: -------------------------------------------------------------------------------- 1 | hello humans! -------------------------------------------------------------------------------- /tests/compiles/mstaticlib.nim: -------------------------------------------------------------------------------- 1 | echo 1234 -------------------------------------------------------------------------------- /tests/ic/config.nims: -------------------------------------------------------------------------------- 1 | --mm:refc 2 | -------------------------------------------------------------------------------- /tests/package/stdlib/stdlib.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/stdlib/tdb.nims: -------------------------------------------------------------------------------- 1 | --styleCheck:off -------------------------------------------------------------------------------- /tests/threads/nim.cfg: -------------------------------------------------------------------------------- 1 | threads:on 2 | -------------------------------------------------------------------------------- /tests/untestable/tpostgres.nim: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/vm/tgorge.bat: -------------------------------------------------------------------------------- 1 | @echo gorge test -------------------------------------------------------------------------------- /lib/pure/coro.nimcfg: -------------------------------------------------------------------------------- 1 | -d:nimCoroutines 2 | -------------------------------------------------------------------------------- /lib/pure/nimprof.nim.cfg: -------------------------------------------------------------------------------- 1 | --profiler:on 2 | -------------------------------------------------------------------------------- /tests/dummy.txt: -------------------------------------------------------------------------------- 1 | Just a simple text for test -------------------------------------------------------------------------------- /tests/gc/gctest.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | -------------------------------------------------------------------------------- /tests/manyloc/packages/package1/p1.babel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/manyloc/packages/package2/p2.babel: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/misc/m15316.nim: -------------------------------------------------------------------------------- 1 | proc foo = (if) 2 | -------------------------------------------------------------------------------- /tests/modules/m9627/a.nim: -------------------------------------------------------------------------------- 1 | var a = 10 2 | -------------------------------------------------------------------------------- /tests/modules/m9627/b.nim: -------------------------------------------------------------------------------- 1 | var b = 9 2 | -------------------------------------------------------------------------------- /tests/msgs/mused2c.nim: -------------------------------------------------------------------------------- 1 | proc baz*() = discard -------------------------------------------------------------------------------- /tests/stdlib/ttypeinfo.nims: -------------------------------------------------------------------------------- 1 | --styleCheck:off -------------------------------------------------------------------------------- /tools/ssl_config_parser.nims: -------------------------------------------------------------------------------- 1 | --d:ssl 2 | -------------------------------------------------------------------------------- /tests/compilerapi/invalid.nim: -------------------------------------------------------------------------------- 1 | noSuchProc() 2 | -------------------------------------------------------------------------------- /tests/destructor/nim.cfg: -------------------------------------------------------------------------------- 1 | --sinkInference:on 2 | -------------------------------------------------------------------------------- /tests/dll/client.nim.cfg: -------------------------------------------------------------------------------- 1 | --define:useNimRtl 2 | -------------------------------------------------------------------------------- /tests/errmsgs/mambtype1.nim: -------------------------------------------------------------------------------- 1 | type Y* = object 2 | -------------------------------------------------------------------------------- /tests/errmsgs/mambtype2.nim: -------------------------------------------------------------------------------- 1 | type Y* = object 2 | -------------------------------------------------------------------------------- /tests/lookups/mambtype1.nim: -------------------------------------------------------------------------------- 1 | type K* = object 2 | -------------------------------------------------------------------------------- /tests/misc/m20149.nim: -------------------------------------------------------------------------------- 1 | let x = 12 2 | echo x 3 | -------------------------------------------------------------------------------- /tests/modules/mrecmod.nim: -------------------------------------------------------------------------------- 1 | import trecmod 2 | -------------------------------------------------------------------------------- /tests/nimdoc/imp.nim: -------------------------------------------------------------------------------- 1 | proc fn5*() = discard 2 | -------------------------------------------------------------------------------- /tests/package_level_objects/mypackage.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/koch.rc: -------------------------------------------------------------------------------- 1 | kochicon ICON "koch.ico" 2 | 3 | 4 | -------------------------------------------------------------------------------- /icons/nim.rc: -------------------------------------------------------------------------------- 1 | nimicon ICON "nim.ico" 2 | 3 | 4 | -------------------------------------------------------------------------------- /nimpretty/nimpretty.nim.cfg: -------------------------------------------------------------------------------- 1 | --define: nimpretty 2 | -------------------------------------------------------------------------------- /tests/assert/config.nims: -------------------------------------------------------------------------------- 1 | --excessiveStackTrace:on 2 | -------------------------------------------------------------------------------- /tests/async/nim.cfg: -------------------------------------------------------------------------------- 1 | --experimental:strictEffects 2 | -------------------------------------------------------------------------------- /tests/compiler/tcmdlinecpuamd64.nim.cfg: -------------------------------------------------------------------------------- 1 | cpu:i386 2 | -------------------------------------------------------------------------------- /tests/compiler/tcmdlineoswin.nim.cfg: -------------------------------------------------------------------------------- 1 | os:linux 2 | -------------------------------------------------------------------------------- /tests/coroutines/tgc.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:nimCoroutines 2 | -------------------------------------------------------------------------------- /tests/coroutines/twait.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:nimCoroutines 2 | -------------------------------------------------------------------------------- /tests/errmsgs/mambparam1.nim: -------------------------------------------------------------------------------- 1 | const test* = "foo" 2 | -------------------------------------------------------------------------------- /tests/errmsgs/mambparam3.nim: -------------------------------------------------------------------------------- 1 | const test* = "bar" 2 | -------------------------------------------------------------------------------- /tests/js/tjsnimscombined.nim: -------------------------------------------------------------------------------- 1 | import std/jsffi 2 | -------------------------------------------------------------------------------- /tests/modules/mincludeprefix.nim: -------------------------------------------------------------------------------- 1 | const bar = 456 2 | -------------------------------------------------------------------------------- /tests/modules/mnamspc1.nim: -------------------------------------------------------------------------------- 1 | import mnamspc2 2 | 3 | -------------------------------------------------------------------------------- /tests/nimdoc/sub/imp.nim: -------------------------------------------------------------------------------- 1 | proc fn4*() = discard 2 | -------------------------------------------------------------------------------- /tests/nimdoc/sub/imp2.nim: -------------------------------------------------------------------------------- 1 | proc fn3*() = discard 2 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter3/various3.nim.cfg: -------------------------------------------------------------------------------- 1 | threads:on -------------------------------------------------------------------------------- /tests/pragmas/monoff1.nim: -------------------------------------------------------------------------------- 1 | proc on*() = discard 2 | -------------------------------------------------------------------------------- /tests/vm/tgorge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "gorge test" -------------------------------------------------------------------------------- /lib/pure/concurrency/threadpool.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | -------------------------------------------------------------------------------- /nimsuggest/tests/t20440.nims: -------------------------------------------------------------------------------- 1 | switch("backend", "js") 2 | -------------------------------------------------------------------------------- /tests/constructors/a.nim: -------------------------------------------------------------------------------- 1 | type A* = object 2 | a: uint8 -------------------------------------------------------------------------------- /tests/coroutines/texceptions.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:nimCoroutines 2 | -------------------------------------------------------------------------------- /tests/coroutines/titerators.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:nimCoroutines 2 | -------------------------------------------------------------------------------- /tests/errmsgs/mb.nim: -------------------------------------------------------------------------------- 1 | type 2 | typ* = distinct string 3 | -------------------------------------------------------------------------------- /tests/import/buzz/m21496.nim: -------------------------------------------------------------------------------- 1 | proc fb*: string = "buzz!" -------------------------------------------------------------------------------- /tests/import/fizz/m21496.nim: -------------------------------------------------------------------------------- 1 | proc fb*: string = "fizz!" -------------------------------------------------------------------------------- /tests/js/tdiscard.nim: -------------------------------------------------------------------------------- 1 | import dom 2 | 3 | discard Node() -------------------------------------------------------------------------------- /tests/lookups/mdisambsym2.nim: -------------------------------------------------------------------------------- 1 | var count*: int = 10 2 | -------------------------------------------------------------------------------- /tests/lookups/mdisambsym3.nim: -------------------------------------------------------------------------------- 1 | const count* = 3.142 2 | -------------------------------------------------------------------------------- /tests/modules/mincludetemplate.nim: -------------------------------------------------------------------------------- 1 | const foo = 123 2 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgA-0.1.0/pkgA.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgB-#head/pkgB.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgB-0.1.0/pkgB.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgC-#aa11/pkgC.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgC-#head/pkgC.nimble: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/parallel/nim.cfg: -------------------------------------------------------------------------------- 1 | threads:on 2 | --experimental 3 | -------------------------------------------------------------------------------- /tests/stdlib/tbitops.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:noUndefinedBitOpts 2 | -------------------------------------------------------------------------------- /tests/template/m1027a.nim: -------------------------------------------------------------------------------- 1 | const version_str* = "mod a" 2 | -------------------------------------------------------------------------------- /tests/template/m1027b.nim: -------------------------------------------------------------------------------- 1 | const version_str* = "mod b" 2 | -------------------------------------------------------------------------------- /tests/tools/compile/config.nims: -------------------------------------------------------------------------------- 1 | switch("path", "$lib/../") -------------------------------------------------------------------------------- /tests/tools/tloadstdin.nims: -------------------------------------------------------------------------------- 1 | --d:nimscriptConfigLoaded 2 | -------------------------------------------------------------------------------- /tests/async/tioselectors.nim.cfg: -------------------------------------------------------------------------------- 1 | threads:on -d:threadsafe 2 | -------------------------------------------------------------------------------- /tests/cpp/fam.h: -------------------------------------------------------------------------------- 1 | struct Test{ 2 | ~Test() { 3 | } 4 | }; 5 | -------------------------------------------------------------------------------- /tests/dll/server.nim.cfg: -------------------------------------------------------------------------------- 1 | --define:useNimRtl 2 | --app:lib 3 | -------------------------------------------------------------------------------- /tests/errmsgs/m8794.nim: -------------------------------------------------------------------------------- 1 | type Foo3* = object 2 | a1: int 3 | -------------------------------------------------------------------------------- /tests/errmsgs/mc.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | typ* = distinct int 4 | -------------------------------------------------------------------------------- /tests/misc/modulea.nim: -------------------------------------------------------------------------------- 1 | type modulea* = object 2 | a: int 3 | -------------------------------------------------------------------------------- /tests/modules/mnotuniquename.nim: -------------------------------------------------------------------------------- 1 | proc flat*() = echo "flat" 2 | -------------------------------------------------------------------------------- /tests/modules/morder_depb.nim: -------------------------------------------------------------------------------- 1 | type Foo* = array[2, byte] 2 | -------------------------------------------------------------------------------- /tests/navigator/minclude.nim: -------------------------------------------------------------------------------- 1 | # An include file. 2 | foo(3) 3 | -------------------------------------------------------------------------------- /tests/template/i2416.nim: -------------------------------------------------------------------------------- 1 | template i2416*() = echo "i2416" 2 | -------------------------------------------------------------------------------- /tests/tools/compile/readme.md: -------------------------------------------------------------------------------- 1 | Test whether the tools compile. -------------------------------------------------------------------------------- /tests/vm/tgorgeex.bat: -------------------------------------------------------------------------------- 1 | @echo gorgeex test 2 | @exit /b 1 3 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_unit.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:useNimRtl 2 | -d:testNimHcr 3 | -------------------------------------------------------------------------------- /tests/errmsgs/mambparam2.nim: -------------------------------------------------------------------------------- 1 | import mambparam1 2 | export test 3 | -------------------------------------------------------------------------------- /tests/exception/m21261.nim: -------------------------------------------------------------------------------- 1 | raise (ref Exception)(msg: "something") -------------------------------------------------------------------------------- /tests/manyloc/nake/nakefile.nim.cfg: -------------------------------------------------------------------------------- 1 | path = "dependencies/nake" 2 | -------------------------------------------------------------------------------- /tests/modules/a/utils.nim: -------------------------------------------------------------------------------- 1 | proc burnMem*(a: int) = 2 | discard 3 | -------------------------------------------------------------------------------- /tests/modules/b/utils.nim: -------------------------------------------------------------------------------- 1 | # module b/utils.nim 2 | let x* = 10 3 | -------------------------------------------------------------------------------- /tests/modules/mimport_in_config.nim: -------------------------------------------------------------------------------- 1 | type 2 | DefinedInB* = int 3 | -------------------------------------------------------------------------------- /tests/msgs/mused2b.nim: -------------------------------------------------------------------------------- 1 | import mused2c 2 | export mused2c 3 | 4 | -------------------------------------------------------------------------------- /tests/stylecheck/foreign_package/foreign_package.nim: -------------------------------------------------------------------------------- 1 | include ../thint -------------------------------------------------------------------------------- /lib/pure/asyncdispatch.nim.cfg: -------------------------------------------------------------------------------- 1 | @if nimdoc: 2 | --os:linux 3 | @end 4 | -------------------------------------------------------------------------------- /tests/c/tcompile.c: -------------------------------------------------------------------------------- 1 | int foo(int a, int b) { 2 | return a+b; 3 | } 4 | -------------------------------------------------------------------------------- /tests/lookups/mambsym2.nim: -------------------------------------------------------------------------------- 1 | type 2 | TExport* = enum a, b, c 3 | 4 | -------------------------------------------------------------------------------- /tests/misc/t16264.nim: -------------------------------------------------------------------------------- 1 | import times 2 | doAssert low(Time) == fromUnix(0) -------------------------------------------------------------------------------- /tests/niminaction/Chapter3/ChatApp/src/client.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | -------------------------------------------------------------------------------- /tests/sandwich/config.nims: -------------------------------------------------------------------------------- 1 | switch("experimental", "typeBoundOps") 2 | -------------------------------------------------------------------------------- /tests/stylecheck/fileinfo.nim: -------------------------------------------------------------------------------- 1 | # fileinfo.nim 2 | type FileInfo* = object -------------------------------------------------------------------------------- /tests/template/mqualifiedtype1.nim: -------------------------------------------------------------------------------- 1 | type A* = object 2 | x*: int 3 | -------------------------------------------------------------------------------- /tests/vm/tgorgeex.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "gorgeex test" 3 | exit 1 4 | -------------------------------------------------------------------------------- /icons/koch.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/icons/koch.ico -------------------------------------------------------------------------------- /icons/koch.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/icons/koch.res -------------------------------------------------------------------------------- /icons/nim.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/icons/nim.ico -------------------------------------------------------------------------------- /icons/nim.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/icons/nim.res -------------------------------------------------------------------------------- /nimdoc/extlinks/util.nim: -------------------------------------------------------------------------------- 1 | proc utilfunction*(x: int): int = 2 | x + 42 3 | -------------------------------------------------------------------------------- /tests/constructors/b.nim: -------------------------------------------------------------------------------- 1 | type B* = object 2 | proc A*(a, b: float): B = discard -------------------------------------------------------------------------------- /tests/cpp/enum.hpp: -------------------------------------------------------------------------------- 1 | namespace namespaced { 2 | enum Enum { A, B, C }; 3 | } 4 | -------------------------------------------------------------------------------- /tests/cpp/foo.c: -------------------------------------------------------------------------------- 1 | 2 | char* myFunc() { 3 | return "Hello world"; 4 | } 5 | -------------------------------------------------------------------------------- /tests/ic/mdefconverter.nim: -------------------------------------------------------------------------------- 1 | 2 | converter toBool*(x: int): bool = x != 0 3 | -------------------------------------------------------------------------------- /tests/import_in_config/nim.cfg: -------------------------------------------------------------------------------- 1 | import = "other" 2 | path = "$projectDir" 3 | -------------------------------------------------------------------------------- /tests/lookups/mdisambsym1.nim: -------------------------------------------------------------------------------- 1 | proc count*(s: string): int = 2 | s.len 3 | -------------------------------------------------------------------------------- /tests/manyloc/packages/noconflicts.nim.cfg: -------------------------------------------------------------------------------- 1 | # Mark noconflicts as project file -------------------------------------------------------------------------------- /tests/manyloc/standalone/barebone.nim.cfg: -------------------------------------------------------------------------------- 1 | --os:standalone 2 | --gc:none 3 | -------------------------------------------------------------------------------- /tests/misc/tmodulea.nim: -------------------------------------------------------------------------------- 1 | from modulea import modulea 2 | 3 | #bug #6731 4 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter6/WikipediaStats/concurrency.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter6/WikipediaStats/parallel_counts.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on -------------------------------------------------------------------------------- /tests/niminaction/Chapter6/WikipediaStats/race_condition.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on -------------------------------------------------------------------------------- /tests/niminaction/Chapter6/WikipediaStats/unguarded_access.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on -------------------------------------------------------------------------------- /tests/sandwich/tsetin.nim: -------------------------------------------------------------------------------- 1 | # issue #18150 2 | 3 | import msetin 4 | foo(1) 5 | -------------------------------------------------------------------------------- /tests/system/helpers/readall_echo.nim: -------------------------------------------------------------------------------- 1 | when true: 2 | echo(stdin.readAll) 3 | -------------------------------------------------------------------------------- /tests/vm/tconst_float_as_int.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #4619 3 | const x: float = 0 4 | -------------------------------------------------------------------------------- /bin/empty.txt: -------------------------------------------------------------------------------- 1 | This file keeps several tools from deleting this subdirectory. 2 | -------------------------------------------------------------------------------- /icons/koch_icon.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/icons/koch_icon.o -------------------------------------------------------------------------------- /icons/nim_icon.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/icons/nim_icon.o -------------------------------------------------------------------------------- /testament/tests/shouldfail/texitcode1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | exitcode: 1 3 | """ 4 | -------------------------------------------------------------------------------- /tests/ccgbugs/m19445.c: -------------------------------------------------------------------------------- 1 | #include "m19445.h" 2 | 3 | const Foo f = {10, 20, 30, 40}; -------------------------------------------------------------------------------- /tests/dir with space/more spaces/mspace.nim: -------------------------------------------------------------------------------- 1 | proc tenTimes*(x: int): int = 10*x 2 | -------------------------------------------------------------------------------- /tests/importalls/m2.nim: -------------------------------------------------------------------------------- 1 | const bar1* = 2 2 | const bar2 = 2 3 | const bar3 = 3 4 | -------------------------------------------------------------------------------- /tests/macros/mparsefile.nim: -------------------------------------------------------------------------------- 1 | let a = 1 2 | let b = 2 3 | let c = 4 | let d = 4 5 | -------------------------------------------------------------------------------- /tests/misc/99bottles.nim: -------------------------------------------------------------------------------- 1 | # Test if the compiler detects invalid module names 2 | -------------------------------------------------------------------------------- /tests/modules/mnamspc2.nim: -------------------------------------------------------------------------------- 1 | # export an identifier: 2 | var 3 | global*: int 4 | -------------------------------------------------------------------------------- /tests/newconfig/foo2/mfoo2.customext: -------------------------------------------------------------------------------- 1 | doAssert defined(nimscript) 2 | echo "123" 3 | -------------------------------------------------------------------------------- /tests/sandwich/helper_module.nim: -------------------------------------------------------------------------------- 1 | 2 | proc indirectlyMixedIn*: int = 3 | 200 4 | -------------------------------------------------------------------------------- /tests/sets/t17385.nim: -------------------------------------------------------------------------------- 1 | import m17385 2 | 3 | let a = Diff[int]() 4 | a.test() 5 | -------------------------------------------------------------------------------- /tests/template/m19277_1.nim: -------------------------------------------------------------------------------- 1 | template foo*(x: untyped) = 2 | echo "got: ", x 3 | -------------------------------------------------------------------------------- /tests/template/m19277_2.nim: -------------------------------------------------------------------------------- 1 | proc foo*(a: string) = 2 | echo "got string: ", a 3 | -------------------------------------------------------------------------------- /tests/template/mqualifiedtype2.nim: -------------------------------------------------------------------------------- 1 | type A* = object 2 | x*: array[1000, byte] 3 | -------------------------------------------------------------------------------- /tests/ccgbugs/t8616.nim: -------------------------------------------------------------------------------- 1 | import pkg8616 / scheduler 2 | 3 | when true: 4 | init() 5 | -------------------------------------------------------------------------------- /tests/concepts/t5888lib/ca.nim: -------------------------------------------------------------------------------- 1 | type 2 | CA* = concept c 3 | c.x is int 4 | 5 | -------------------------------------------------------------------------------- /tests/destructor/helper.nim: -------------------------------------------------------------------------------- 1 | type 2 | MyTestObject*[T] = object 3 | p: ptr T 4 | -------------------------------------------------------------------------------- /tests/enum/m16462_1.nim: -------------------------------------------------------------------------------- 1 | type 2 | Scancode* {.pure.} = enum 3 | SCANCODE_LEFT = 80 -------------------------------------------------------------------------------- /tests/enum/m16462_2.nim: -------------------------------------------------------------------------------- 1 | type 2 | Scancode* {.pure.} = enum 3 | SCANCODE_LEFT = 80 -------------------------------------------------------------------------------- /tests/newconfig/mymath.nim: -------------------------------------------------------------------------------- 1 | 2 | 3 | proc ln*(x: float): float = 4 | return 0.5 5 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgA-0.1.0/pkgA/module.nim: -------------------------------------------------------------------------------- 1 | proc pkgATest*(): int = 1 -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgB-0.1.0/pkgB/module.nim: -------------------------------------------------------------------------------- 1 | proc pkgBTest*(): int64 = 0 -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgC-#aa11/pkgC/module.nim: -------------------------------------------------------------------------------- 1 | proc pkgCTest*(): int64 = 1 -------------------------------------------------------------------------------- /tests/niminaction/Chapter6/WikipediaStats/concurrency_regex.nim.cfg: -------------------------------------------------------------------------------- 1 | --threads:on 2 | -------------------------------------------------------------------------------- /tests/pragmas/cfunction.c: -------------------------------------------------------------------------------- 1 | 2 | int cfunction(void) { 3 | return NUMBER_HERE; 4 | } 5 | -------------------------------------------------------------------------------- /tests/tools/second.nim: -------------------------------------------------------------------------------- 1 | import tables 2 | 3 | let dataEx* = {1: 2, 3: 4}.toTable 4 | -------------------------------------------------------------------------------- /lib/nimhcr.nim.cfg: -------------------------------------------------------------------------------- 1 | --app:lib 2 | --threads:on 3 | -d:useNimRtl 4 | -d:createNimHcr 5 | 6 | -------------------------------------------------------------------------------- /tests/arc/bmodule.nim: -------------------------------------------------------------------------------- 1 | import cmodule 2 | 3 | for i in @[1, 2, 3].cycle(): 4 | echo i 5 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_0_5.nim: -------------------------------------------------------------------------------- 1 | 2 | proc getInt*(): int = return 42 # back to the answer... 3 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_1_2.nim: -------------------------------------------------------------------------------- 1 | 2 | import nimhcr_2 3 | 4 | proc f_1*(): int = return f_2() 5 | -------------------------------------------------------------------------------- /tests/manyloc/keineschweine/dependencies/sfml/sfml_vector.nim: -------------------------------------------------------------------------------- 1 | import sfml, math, strutils 2 | -------------------------------------------------------------------------------- /tests/modules/proxy_module.nim: -------------------------------------------------------------------------------- 1 | import definitions 2 | export definitions except p 3 | 4 | -------------------------------------------------------------------------------- /tests/modules/tnotuniquename_dir/mnotuniquename.nim: -------------------------------------------------------------------------------- 1 | 2 | proc nested*() = echo "nested" 3 | -------------------------------------------------------------------------------- /tests/nimble/readme.md: -------------------------------------------------------------------------------- 1 | This directory contains tests for the --nimblePath feature. 2 | 3 | -------------------------------------------------------------------------------- /tests/objects/mobjconstr_msgs.nim: -------------------------------------------------------------------------------- 1 | type 2 | PrivateField* = object 3 | priv: string 4 | -------------------------------------------------------------------------------- /tests/system/temptyecho.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "\n" 3 | """ 4 | 5 | echo() 6 | 7 | -------------------------------------------------------------------------------- /tests/tools/compile/tkoch.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | include koch -------------------------------------------------------------------------------- /tests/arc/nim.cfg: -------------------------------------------------------------------------------- 1 | --sinkInference:on 2 | --warningAserror:ProveInit 3 | --warningAserror:Uninit -------------------------------------------------------------------------------- /tests/concepts/t20237.nim: -------------------------------------------------------------------------------- 1 | type Foo* = concept 2 | ## doc comment 3 | proc foo(x: Self) 4 | -------------------------------------------------------------------------------- /tests/generics/mmodule_same_as_proc.nim: -------------------------------------------------------------------------------- 1 | 2 | proc mmodule_same_as_proc*(x: string) = discard 3 | -------------------------------------------------------------------------------- /tests/misc/tparedef.nim: -------------------------------------------------------------------------------- 1 | # This test is now superfluous: 2 | 3 | proc a(a: int) = 4 | return 5 | -------------------------------------------------------------------------------- /tests/modules/b/module_name_clashes.nim: -------------------------------------------------------------------------------- 1 | # See `tmodule_name_clashes` 2 | 3 | type B* = object 4 | -------------------------------------------------------------------------------- /tests/modules/seq.nim: -------------------------------------------------------------------------------- 1 | var seq: seq[int] 2 | var b: seq[float] 3 | 4 | echo seq 5 | echo b 6 | -------------------------------------------------------------------------------- /tests/modules/t8665.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | import treorder 6 | -------------------------------------------------------------------------------- /tests/modules/timport_in_config.nim.cfg: -------------------------------------------------------------------------------- 1 | --import: "strutils" 2 | --import: "mimport_in_config" 3 | -------------------------------------------------------------------------------- /tests/msgs/thints_off.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--hints:off" 3 | """ 4 | doAssert true 5 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgB-#head/pkgB/module.nim: -------------------------------------------------------------------------------- 1 | proc pkgBTest*(): int64 = 0xDEADBEEF -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/simplePkgs/pkgC-#head/pkgC/module.nim: -------------------------------------------------------------------------------- 1 | proc pkgCTest*(): int64 = 0xDEADBEEF -------------------------------------------------------------------------------- /tests/package/stdlib/system.nim: -------------------------------------------------------------------------------- 1 | # this module is part of tstdlib_name_not_special 2 | doAssert true -------------------------------------------------------------------------------- /tests/rectest.nim: -------------------------------------------------------------------------------- 1 | # Test the error message 2 | 3 | proc main() = 4 | main() 5 | 6 | main() 7 | -------------------------------------------------------------------------------- /tests/tools/dontmentionme.nim: -------------------------------------------------------------------------------- 1 | {.used.} 2 | 3 | proc nothing* = echo "nothing to see here" 4 | -------------------------------------------------------------------------------- /tests/tuples/twrong_generic_caching.nim: -------------------------------------------------------------------------------- 1 | 2 | import parsecfg 3 | 4 | import asynchttpserver 5 | -------------------------------------------------------------------------------- /tools/niminst/setup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/tools/niminst/setup.ico -------------------------------------------------------------------------------- /nimdoc/test_out_index_dot_html/foo.nim: -------------------------------------------------------------------------------- 1 | proc foo*() = 2 | ## I do foo 3 | echo "foo says hello!" 4 | -------------------------------------------------------------------------------- /tests/arc/t14864.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:arc $file" 3 | """ 4 | 5 | import bmodule 6 | -------------------------------------------------------------------------------- /tests/ccgbugs/m1/defs.nim: -------------------------------------------------------------------------------- 1 | type MyObj* = object 2 | field1*: int 3 | s*: string 4 | ch*: char 5 | -------------------------------------------------------------------------------- /tests/ccgbugs/m2/defs.nim: -------------------------------------------------------------------------------- 1 | type MyObj* = object 2 | s*: string 3 | field1*: int 4 | ch*: char 5 | -------------------------------------------------------------------------------- /tests/ccgbugs/pkg8616/rtarray.nim: -------------------------------------------------------------------------------- 1 | proc head*[T](pp: var array[1,T]): var T = 2 | result = pp[0] 3 | -------------------------------------------------------------------------------- /tests/ccgbugs/t20787.nim: -------------------------------------------------------------------------------- 1 | type 2 | Obj = object 3 | f: UncheckedArray[byte] 4 | let o = new Obj -------------------------------------------------------------------------------- /tests/compiler/tcmdlineclib.nim: -------------------------------------------------------------------------------- 1 | proc test(): int {.importc, cdecl.} 2 | 3 | doAssert test() == 123 4 | -------------------------------------------------------------------------------- /tests/concepts/t5888lib/opt.nim: -------------------------------------------------------------------------------- 1 | import ca 2 | 3 | type 4 | Opt* = object 5 | x*: int 6 | 7 | -------------------------------------------------------------------------------- /tests/converter/m18986.nim: -------------------------------------------------------------------------------- 1 | import std/macros 2 | 3 | converter Lit*(x: uint): NimNode = newLit(x) 4 | -------------------------------------------------------------------------------- /tests/lookups/issue_23032/deep_scope.nim: -------------------------------------------------------------------------------- 1 | type A*[T] = object 2 | proc foo*(a: A[int]): bool = false 3 | -------------------------------------------------------------------------------- /tests/lookups/mambsym4.nim: -------------------------------------------------------------------------------- 1 | # Module B 2 | var x*: int 3 | proc foo*(b: int) = 4 | echo "B: ", b 5 | -------------------------------------------------------------------------------- /tests/misc/t12480.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'return' not allowed here" 3 | """ 4 | 5 | return -------------------------------------------------------------------------------- /tests/misc/t15351.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | """ 4 | var 5 | ## TODO: broken 6 | -------------------------------------------------------------------------------- /tests/modules/mexport2b.nim: -------------------------------------------------------------------------------- 1 | proc printXyz*() = echo "xyz" 2 | 3 | proc foo*(x: int) = echo "B.foo" 4 | -------------------------------------------------------------------------------- /tests/modules/mforwarded_pure_enum2.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | PureEnum* {.pure.} = enum 4 | x, y, z 5 | -------------------------------------------------------------------------------- /tests/modules/mrange.nim: -------------------------------------------------------------------------------- 1 | 2 | proc range*() = echo "yo" 3 | 4 | proc set*(a: int) = 5 | discard 6 | -------------------------------------------------------------------------------- /tests/package_level_objects/definefoo.nim: -------------------------------------------------------------------------------- 1 | type 2 | Foo* {.package.} = object 3 | x, y: int 4 | -------------------------------------------------------------------------------- /tests/tools/compile/tdeps.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | include tools/deps 6 | -------------------------------------------------------------------------------- /tools/niminst/nim-file.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/tools/niminst/nim-file.ico -------------------------------------------------------------------------------- /tools/niminst/uninstall.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/tools/niminst/uninstall.ico -------------------------------------------------------------------------------- /icons/nim-i386-windows-vcc.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/icons/nim-i386-windows-vcc.res -------------------------------------------------------------------------------- /tests/destructor/t25341_aux/a.nim: -------------------------------------------------------------------------------- 1 | import ./module 2 | 3 | proc a*() = 4 | discard make1[4]().make2() 5 | -------------------------------------------------------------------------------- /tests/generics/mpragma1.nim: -------------------------------------------------------------------------------- 1 | macro aMacro*(u:untyped):untyped = 2 | echo "in macro" 3 | result = u 4 | -------------------------------------------------------------------------------- /tests/js/t8231.nim: -------------------------------------------------------------------------------- 1 | import strutils 2 | 3 | doAssert formatSize(2462056448, '.', bpIEC, false) == "2.293GiB" -------------------------------------------------------------------------------- /tests/js/tfloatround.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | 3 4 | ''' 5 | """ 6 | 7 | echo int(22 / 7) 8 | -------------------------------------------------------------------------------- /tests/lookups/mambsym3.nim: -------------------------------------------------------------------------------- 1 | # Module A 2 | var x*: string 3 | proc foo*(a: string) = 4 | echo "A: ", a 5 | -------------------------------------------------------------------------------- /tests/misc/minit.nim: -------------------------------------------------------------------------------- 1 | # Test the new initialization for modules 2 | write(stdout, "Hello from module! ") 3 | -------------------------------------------------------------------------------- /tests/modules/morder_depa.nim: -------------------------------------------------------------------------------- 1 | 2 | import morder_depb 3 | 4 | proc Foo*(x: int): Foo = discard 5 | 6 | -------------------------------------------------------------------------------- /tests/modules/tutils_ab.nim: -------------------------------------------------------------------------------- 1 | import a/utils as autils, b/utils 2 | 3 | # bug #12420 4 | 5 | burnMem(x) 6 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter7/Tweeter/tests/database_test.nims: -------------------------------------------------------------------------------- 1 | --path:"../src" 2 | #switch("path", "./src") 3 | -------------------------------------------------------------------------------- /tests/parser/t19430.nim: -------------------------------------------------------------------------------- 1 | let x = proc() = ## abc 2 | let y = 3 #[tt.Error 3 | ^ invalid indentation]# 4 | -------------------------------------------------------------------------------- /tests/proc/mdefaultprocparam.nim: -------------------------------------------------------------------------------- 1 | 2 | 3 | proc p*(f = (proc(): string = "hi")) = 4 | echo f() 5 | 6 | -------------------------------------------------------------------------------- /tests/sandwich/mdollar3.nim: -------------------------------------------------------------------------------- 1 | proc debug*[T](obj: T) = 2 | echo "debugging: ", obj # calls generic `$` 3 | -------------------------------------------------------------------------------- /tests/testdata/jsonwithextradata.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": 123, 3 | "bar": 456 4 | } 5 | 6 | "foobar" 7 | -------------------------------------------------------------------------------- /tests/typerel/tuncheckedarray_eq.nim: -------------------------------------------------------------------------------- 1 | type p = ptr UncheckedArray[char] 2 | doAssert p is ptr UncheckedArray -------------------------------------------------------------------------------- /tests/types/ttypeofobjconstr.nim: -------------------------------------------------------------------------------- 1 | # issue #24751 2 | 3 | type A = object 4 | 5 | var a: typeof(A()) 6 | -------------------------------------------------------------------------------- /tools/detect/.gitignore: -------------------------------------------------------------------------------- 1 | pre.c 2 | pre.i 3 | genconsts.c 4 | other_consts.nim 5 | linux_amd64_consts.nim 6 | -------------------------------------------------------------------------------- /icons/koch-amd64-windows-vcc.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/icons/koch-amd64-windows-vcc.res -------------------------------------------------------------------------------- /icons/koch-i386-windows-vcc.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/icons/koch-i386-windows-vcc.res -------------------------------------------------------------------------------- /icons/nim-amd64-windows-vcc.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/icons/nim-amd64-windows-vcc.res -------------------------------------------------------------------------------- /nimsuggest/tests/fixtures/mdep_v1.nim: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | type 7 | Foo* = object 8 | x*, y*: int 9 | -------------------------------------------------------------------------------- /tests/errmsgs/t23060.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: '♔♕♖♗♘♙'" 3 | """ 4 | 5 | ♔♕♖♗♘♙ = 1 -------------------------------------------------------------------------------- /tests/errmsgs/tstaticexprnotype.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: reject 3 | """ 4 | 5 | let x = static: discard 6 | -------------------------------------------------------------------------------- /tests/global/globalaux2.nim: -------------------------------------------------------------------------------- 1 | import globalaux 2 | 3 | echo "in globalaux2: ", globalInstance[int]().val 4 | 5 | -------------------------------------------------------------------------------- /tests/import/t22065.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot open file: ./sugar" 3 | """ 4 | 5 | import ./sugar -------------------------------------------------------------------------------- /tests/manyloc/argument_parser/ex_wget.nim.cfg: -------------------------------------------------------------------------------- 1 | # This file exists only to mark 'ex_wget' as the project file 2 | -------------------------------------------------------------------------------- /tests/manyloc/packages/os.nim: -------------------------------------------------------------------------------- 1 | 2 | # Overrides lib/pure/os.nim 3 | 4 | proc yay* = echo "new os.nim" 5 | 6 | -------------------------------------------------------------------------------- /tests/modules/UpperCased.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #5076 3 | 4 | var str*: string 5 | 6 | UpperCased.str = "hello" 7 | -------------------------------------------------------------------------------- /tests/modules/mmodule_same_proc_client.nim: -------------------------------------------------------------------------------- 1 | 2 | proc mmodule_same_proc_client*(x: string): bool = x.len > 0 3 | -------------------------------------------------------------------------------- /tests/parser/tbinarynotindented.nim: -------------------------------------------------------------------------------- 1 | type Foo = ref int 2 | not nil #[tt.Error 3 | ^ invalid indentation]# 4 | -------------------------------------------------------------------------------- /tests/pragmas/foobar.nim: -------------------------------------------------------------------------------- 1 | import macros 2 | macro async*(body: untyped): untyped = 3 | return newStmtList() 4 | -------------------------------------------------------------------------------- /tests/stdlib/t9754.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | joinable: false 3 | """ 4 | 5 | import tmarshal 6 | import tparsesql -------------------------------------------------------------------------------- /tests/stdlib/tjsontestsuite.nim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nim-lang/Nim/HEAD/tests/stdlib/tjsontestsuite.nim -------------------------------------------------------------------------------- /tests/stylecheck/t20397.nim: -------------------------------------------------------------------------------- 1 | {.hintAsError[Name]:on.} 2 | var a_b = 1 3 | discard a_b 4 | {.hintAsError[Name]:off.} -------------------------------------------------------------------------------- /tests/template/mlt.nim: -------------------------------------------------------------------------------- 1 | 2 | type Point* = ref object of RootObj 3 | proc `>`*(p1, p2: Point): bool = false 4 | -------------------------------------------------------------------------------- /tests/testdata/data.csv: -------------------------------------------------------------------------------- 1 | Algo_A; Algo_B; Algo_C 2 | 12; 12; 16 3 | 2; 5; 9 4 | 63; 65.3; 90 5 | 0; 1.2; 3 6 | 7 | -------------------------------------------------------------------------------- /tests/tools/compile/tniminst.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | include tools/niminst/niminst -------------------------------------------------------------------------------- /nimpretty/tests/simple4.nim: -------------------------------------------------------------------------------- 1 | proc readBuffer*(f: AsyncFile, buf: pointer, size: int): Future[int] = 2 | discard 3 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tmaxcodesize.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | maxcodesize: 1 3 | """ 4 | 5 | echo "Hello World" 6 | -------------------------------------------------------------------------------- /tests/arc/cmodule.nim: -------------------------------------------------------------------------------- 1 | iterator cycle*[T](s: openArray[T]): T = 2 | let s = @s 3 | for x in s: 4 | yield x 5 | -------------------------------------------------------------------------------- /tests/ccgbugs/xoa9578.nim: -------------------------------------------------------------------------------- 1 | import t9578 2 | 3 | proc testOpenArray*(x: var openArray[mytype]) = 4 | f(x[0].addr) 5 | -------------------------------------------------------------------------------- /tests/generics/topensymimport.nim: -------------------------------------------------------------------------------- 1 | # issue #23386 2 | 3 | import mopensymimport2 4 | 5 | doAssert g(int) == "f" 6 | -------------------------------------------------------------------------------- /tests/import/t23167.nim: -------------------------------------------------------------------------------- 1 | # bug #23167 2 | template sharedImport() = 3 | import std / os 4 | 5 | sharedImport() 6 | -------------------------------------------------------------------------------- /tests/modules/mforwarded_pure_enum.nim: -------------------------------------------------------------------------------- 1 | 2 | import mforwarded_pure_enum2 3 | export mforwarded_pure_enum2.PureEnum 4 | -------------------------------------------------------------------------------- /tests/modules/t9627.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "109" 3 | """ 4 | 5 | include m9627 / [a, b] 6 | 7 | echo a, b 8 | -------------------------------------------------------------------------------- /tests/tools/compile/tdetect.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | include tools/detect/detect 6 | -------------------------------------------------------------------------------- /tests/arc/t16458.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--gc:orc --d:useNimRtl" 3 | action: "compile" 4 | """ 5 | 6 | echo 134 -------------------------------------------------------------------------------- /tests/constructors/t18990.nim: -------------------------------------------------------------------------------- 1 | import a, b 2 | discard A(1f, 1f) # works 3 | proc x(b = A(1f, 1f)) = discard # doesn't work -------------------------------------------------------------------------------- /tests/cpp/tnativesockets.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | outputsub: "" 4 | """ 5 | 6 | import nativesockets 7 | -------------------------------------------------------------------------------- /tests/cpp/ttypeinfo2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | """ 4 | # bug #2841 5 | import typeinfo 6 | var tt: Any 7 | -------------------------------------------------------------------------------- /tests/enum/t16462.nim: -------------------------------------------------------------------------------- 1 | import m16462_1 except Scancode 2 | import m16462_2 3 | 4 | # bug #16462 5 | let a = SCANCODE_LEFT -------------------------------------------------------------------------------- /tests/errmsgs/t18327.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "parameter 'n' requires a type" 3 | """ 4 | 5 | proc fn3(n) = discard -------------------------------------------------------------------------------- /tests/generics/t14509.nim: -------------------------------------------------------------------------------- 1 | import m14509 2 | 3 | var v: VecIntrin[4, float32] 4 | doAssert $v == "[0.0, 0.0, 0.0, 0.0]" 5 | -------------------------------------------------------------------------------- /tests/importalls/mt4b.nim: -------------------------------------------------------------------------------- 1 | from ./m1 {.all.} as m2 import nil 2 | doAssert not compiles(foo1) 3 | doAssert m2.foo1 == 2 4 | -------------------------------------------------------------------------------- /tests/js/t7127.nim: -------------------------------------------------------------------------------- 1 | doAssertRaises(DivByZeroDefect): discard 1 mod 0 2 | doAssertRaises(DivByZeroDefect): discard 1 div 0 -------------------------------------------------------------------------------- /tests/manyloc/standalone2/tavr.nim.cfg: -------------------------------------------------------------------------------- 1 | --gc:arc 2 | --cpu:avr 3 | --os:standalone 4 | --compileOnly 5 | --threads:off 6 | -------------------------------------------------------------------------------- /tests/threads/tjsthreads.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "js" 3 | matrix: "--threads:on" 4 | """ 5 | 6 | echo 123 7 | -------------------------------------------------------------------------------- /tests/tools/config.nims: -------------------------------------------------------------------------------- 1 | --d:nimPreviewSlimSystem 2 | --d:nimPreviewCstringConversion 3 | --d:nimPreviewProcConversion 4 | -------------------------------------------------------------------------------- /tests/vm/tcgemptycallarg.nim: -------------------------------------------------------------------------------- 1 | static: 2 | doAssertRaises(ValueError): 3 | raise newException(ValueError, "Yes") 4 | -------------------------------------------------------------------------------- /nimpretty/tests/expected/simple4.nim: -------------------------------------------------------------------------------- 1 | proc readBuffer*(f: AsyncFile, buf: pointer, size: int): Future[int] = 2 | discard 3 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/toutput.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | done 4 | ''' 5 | """ 6 | 7 | echo "broken" 8 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/toutputsub.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "something else" 3 | """ 4 | 5 | echo "Hello World!" 6 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/ttimeout.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | timeout: "0.1" 3 | """ 4 | 5 | import os 6 | 7 | os.sleep(1000) 8 | -------------------------------------------------------------------------------- /tests/assert/tunittests.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "" 3 | """ 4 | import "../template/utemplates", "../closure/uclosures" 5 | -------------------------------------------------------------------------------- /tests/compiler/samplelib.nim: -------------------------------------------------------------------------------- 1 | # Sample library used by tcmdlineclib.nim 2 | proc test(): int {.cdecl, exportc, dynlib.} = 123 3 | -------------------------------------------------------------------------------- /tests/converter/mdontleak.nim: -------------------------------------------------------------------------------- 1 | 2 | converter toBool(x: uint32): bool = x != 0 3 | # Note: This convertes is not exported! 4 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_0.nim: -------------------------------------------------------------------------------- 1 | 2 | let g_0 = 1000 # new value! but also a "new" global :) 3 | 4 | proc getInt*(): int = return g_0 5 | -------------------------------------------------------------------------------- /tests/errmsgs/t5282.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'x'" 3 | """ 4 | 5 | type x = distinct x 6 | -------------------------------------------------------------------------------- /tests/exprs/thighCString.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "5" 3 | """ 4 | let test = cstring("foobar") 5 | 6 | echo high(test) 7 | -------------------------------------------------------------------------------- /tests/ic/mimportsb.nim: -------------------------------------------------------------------------------- 1 | proc fnb1*(): int = 1 2 | proc fnb2*(): int = 2 3 | proc hfnb3(): int = 3 4 | proc hfnb4(): int = 4 5 | -------------------------------------------------------------------------------- /tests/init/tlet_uninit2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'let' symbol requires an initialization" 3 | """ 4 | 5 | let x: int -------------------------------------------------------------------------------- /tests/js/tjsnimscombined.nims: -------------------------------------------------------------------------------- 1 | # test the condition where both `js` and `nimscript` are defined (nimscript receives priority) 2 | -------------------------------------------------------------------------------- /tests/lookups/mambsys2.nim: -------------------------------------------------------------------------------- 1 | type 2 | TExport* = enum x, y, z # exactly the same type! 3 | 4 | proc foo*(x: int) = discard 5 | -------------------------------------------------------------------------------- /tests/macros/t14329.nim: -------------------------------------------------------------------------------- 1 | import macros 2 | 3 | macro myMacro(n) = 4 | let x = if true: newLit"test" else: error "error", n 5 | -------------------------------------------------------------------------------- /tests/modules/tseq.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | joinable: false 3 | output: '''@[] 4 | @[] 5 | ''' 6 | """ 7 | 8 | import seq 9 | -------------------------------------------------------------------------------- /tests/tuples/mnimsconstunpack.nim: -------------------------------------------------------------------------------- 1 | proc foo(): tuple[a, b: string] = 2 | result = ("a", "b") 3 | 4 | const (a, b*) = foo() 5 | -------------------------------------------------------------------------------- /tests/types/t6969.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'object' for var" 3 | line: 6 4 | """ 5 | 6 | var a: object 7 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_0_6.nim: -------------------------------------------------------------------------------- 1 | 2 | let g_0 = 1000 # new value! but also a "new" global :) 3 | 4 | proc getInt*(): int = return g_0 5 | -------------------------------------------------------------------------------- /tests/js/t11697.nim: -------------------------------------------------------------------------------- 1 | import tables 2 | 3 | var xs: Table[int, Table[int, int]] 4 | 5 | doAssertRaises(KeyError): reset xs[0] 6 | -------------------------------------------------------------------------------- /tests/manyloc/packages/package1/strutils.nim: -------------------------------------------------------------------------------- 1 | 2 | # Overrides lib/pure/os.nim 3 | 4 | proc foo* = echo "package1/strutils" 5 | 6 | -------------------------------------------------------------------------------- /tests/manyloc/packages/package2/strutils.nim: -------------------------------------------------------------------------------- 1 | 2 | # Overrides lib/pure/os.nim 3 | 4 | proc foo* = echo "package2/strutils" 5 | 6 | -------------------------------------------------------------------------------- /tests/misc/t9710.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--debugger:native" 3 | """ 4 | # bug #9710 5 | for i in 1 || 200: 6 | discard i 7 | -------------------------------------------------------------------------------- /tests/modules/definitions.nim: -------------------------------------------------------------------------------- 1 | var v*: int 2 | proc p* = echo "proc p called" 3 | template t* = echo "template t expanded" 4 | 5 | -------------------------------------------------------------------------------- /tests/modules/tincludeprefix.nim: -------------------------------------------------------------------------------- 1 | include ./[mincludeprefix, mincludetemplate] 2 | doAssert foo == 123 3 | doAssert bar == 456 4 | -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/linkedPkgs/pkgA-0.1.0/pkgA.nimble-link: -------------------------------------------------------------------------------- 1 | ../../simplePkgs/pkgA-0.1.0/pkgA.nimble 2 | ../../simplePkgs/pkgA-0.1.0/ -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/linkedPkgs/pkgB-#head/pkgB.nimble-link: -------------------------------------------------------------------------------- 1 | ../../simplePkgs/pkgB-#head/pkgB.nimble 2 | ../../simplePkgs/pkgB-#head/ -------------------------------------------------------------------------------- /tests/nimble/nimbleDir/linkedPkgs/pkgB-0.1.0/pkgB.nimble-link: -------------------------------------------------------------------------------- 1 | ../../simplePkgs/pkgB-0.1.0/pkgB.nimble 2 | ../../simplePkgs/pkgB-0.1.0/ -------------------------------------------------------------------------------- /tests/statictypes/t5780.nim: -------------------------------------------------------------------------------- 1 | type StringArray[N:int] = array[N, string] 2 | let a = ["one", "two"] 3 | doAssert a is StringArray 4 | -------------------------------------------------------------------------------- /tests/stdlib/nre/optional_nonstrict.nim: -------------------------------------------------------------------------------- 1 | import options 2 | converter option2val*[T](val: Option[T]): T = 3 | return val.get() 4 | -------------------------------------------------------------------------------- /tests/casestmt/tcase_issues.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c js" 3 | """ 4 | 5 | block: # bug #24031 6 | case 0 7 | else: discard -------------------------------------------------------------------------------- /tests/converter/tconvcolors.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "16777215A" 3 | """ 4 | 5 | import colors 6 | 7 | echo int32(colWhite), 'A' 8 | -------------------------------------------------------------------------------- /tests/errmsgs/t18983.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'A'" 3 | """ 4 | 5 | type 6 | A* = A 7 | B = (A,) 8 | -------------------------------------------------------------------------------- /tests/lookups/issue_23172/m23172.nim: -------------------------------------------------------------------------------- 1 | type 2 | Foo* = object 3 | Bar* = object 4 | 5 | func `$`*(x: Foo | Bar): string = 6 | "X" 7 | -------------------------------------------------------------------------------- /tests/macros/tsame_name_497.nim: -------------------------------------------------------------------------------- 1 | 2 | import macro_bug 3 | 4 | type TObj = object 5 | 6 | proc f(o: TObj) {.macro_bug.} = discard 7 | -------------------------------------------------------------------------------- /tests/misc/mvarious.nim: -------------------------------------------------------------------------------- 1 | # Test a submodule 2 | 3 | #type 4 | # TStringArr = array[0.. *] of string 5 | 6 | proc exportme* = discard 7 | -------------------------------------------------------------------------------- /tests/overload/importA.nim: -------------------------------------------------------------------------------- 1 | type 2 | Field* = object 3 | elemSize*: int 4 | 5 | template `+`*(x: untyped, y: Field): untyped = x 6 | -------------------------------------------------------------------------------- /tests/pragmas/tuserpragma.nim: -------------------------------------------------------------------------------- 1 | 2 | {.pragma: rtl, cdecl, exportc.} 3 | 4 | proc myproc(x, y: int): int {.rtl} = 5 | nil 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/pragmas/warn_module.nim: -------------------------------------------------------------------------------- 1 | 2 | {.warning[UnusedImport]: off.} 3 | 4 | import hashes 5 | 6 | proc test(a: float): float = 7 | a 8 | -------------------------------------------------------------------------------- /tests/sandwich/msetiter2.nim: -------------------------------------------------------------------------------- 1 | import sets, sequtils 2 | 3 | proc dedupe*[T](arr: openArray[T]): seq[T] = 4 | arr.toHashSet.toSeq 5 | -------------------------------------------------------------------------------- /tests/stylecheck/foreign_package/foreign_package.nimble: -------------------------------------------------------------------------------- 1 | # See `tstyleCheck` 2 | # Needed to mark `mstyleCheck` as a foreign package. 3 | -------------------------------------------------------------------------------- /tests/typerel/ttypedesc_as_genericparam1_orc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:orc" 3 | """ 4 | 5 | doAssert repr(int) == "int" 6 | -------------------------------------------------------------------------------- /tests/types/told_pragma_syntax1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | """ 4 | 5 | type Foo = object {.final.} 6 | -------------------------------------------------------------------------------- /tests/types/told_pragma_syntax2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | """ 4 | 5 | type Bar {.final.} [T] = object 6 | -------------------------------------------------------------------------------- /tests/vm/mscriptcompiletime.nim: -------------------------------------------------------------------------------- 1 | # bug.nim 2 | var bar* {.compileTime.} = 1 3 | 4 | proc dummy = discard 5 | 6 | static: 7 | inc bar -------------------------------------------------------------------------------- /lib/impure/nre/.gitignore: -------------------------------------------------------------------------------- 1 | # all executables 2 | * 3 | !*/ 4 | !*.* 5 | *.exe 6 | 7 | # Wildcard patterns. 8 | *.swp 9 | nimcache 10 | -------------------------------------------------------------------------------- /nimsuggest/config.nims: -------------------------------------------------------------------------------- 1 | # xxx not sure why this flag isn't needed: switch("processing", "filenames") 2 | switch("filenames", "canonical") 3 | -------------------------------------------------------------------------------- /nimsuggest/tests/fixtures/mdep_v2.nim: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | type 7 | Foo* = object 8 | x*, y*: int 9 | z*: string 10 | -------------------------------------------------------------------------------- /nimsuggest/tests/module_20265.nim: -------------------------------------------------------------------------------- 1 | type A* = tuple 2 | a: int 3 | b: int 4 | 5 | var x*: A = (a: 2, b: 10) 6 | var y* = (a: 2, b: 10) 7 | -------------------------------------------------------------------------------- /tests/compilerapi/exposed.nim: -------------------------------------------------------------------------------- 1 | 2 | proc addFloats*(x, y, z: float): float = 3 | discard "implementation overridden by tcompilerapi.nim" 4 | -------------------------------------------------------------------------------- /tests/destructor/tconst_smart_ptr.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | """ 4 | 5 | import const_smart_ptr 6 | 7 | discard test(0) 8 | -------------------------------------------------------------------------------- /tests/errmsgs/t8610.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'typedesc[int]' for const" 3 | """ 4 | ## bug #8610 5 | const Foo = int 6 | -------------------------------------------------------------------------------- /tests/exception/m22469.nim: -------------------------------------------------------------------------------- 1 | # ModuleB 2 | echo "First top-level statement of ModuleB" 3 | echo high(int) + 1 4 | echo "ModuleB last statement" -------------------------------------------------------------------------------- /tests/generics/mpragma2.nim: -------------------------------------------------------------------------------- 1 | import mpragma1 2 | proc p*[T]() = 3 | proc inner() {.aMacro.} = 4 | discard 5 | inner() 6 | discard 7 | -------------------------------------------------------------------------------- /tests/generics/taliashijack.nim: -------------------------------------------------------------------------------- 1 | # issue #23977 2 | 3 | type Foo[T] = int 4 | 5 | proc foo(T: typedesc) = 6 | var a: T 7 | 8 | foo(int) 9 | -------------------------------------------------------------------------------- /tests/global/a_module.nim: -------------------------------------------------------------------------------- 1 | # a.nim 2 | {.push stackTrace: off.} 3 | proc foo*(): int = 4 | var a {.global.} = 0 5 | result = a 6 | {.pop.} -------------------------------------------------------------------------------- /tests/import/t22208.nim: -------------------------------------------------------------------------------- 1 | import fizz/m21496 as alas 2 | import buzz/m21496 3 | 4 | # bug #21496 5 | 6 | doAssert m21496.fb() == "buzz!" 7 | -------------------------------------------------------------------------------- /tests/importalls/mt4.nim: -------------------------------------------------------------------------------- 1 | import ./m1 {.all.} except foo1 2 | doAssert foo2 == 2 3 | doAssert declared(foo2) 4 | doAssert not compiles(foo1) 5 | -------------------------------------------------------------------------------- /tests/js/tcsymbol.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--cc:gcc; --cc:tcc" 3 | """ 4 | 5 | doAssert not defined(gcc) 6 | doAssert not defined(tcc) -------------------------------------------------------------------------------- /tests/js/testtojsstr.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output = "И\n" 3 | """ 4 | 5 | let s: string = "И\n" 6 | let cs = s.cstring 7 | 8 | echo $s 9 | -------------------------------------------------------------------------------- /tests/manyloc/named_argument_bug/main.nim.cfg: -------------------------------------------------------------------------------- 1 | # this file only exists to mark 'main.nim' as the main file 2 | 3 | --path:"$projectpath" 4 | -------------------------------------------------------------------------------- /tests/modules/tfowarded_pure_enum.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''z''' 3 | """ 4 | 5 | import mforwarded_pure_enum as t2 6 | 7 | echo z 8 | -------------------------------------------------------------------------------- /tests/parser/t19662.nim: -------------------------------------------------------------------------------- 1 | var i: int # bug #19662 2 | echo i 3 | 4 | discard """ 5 | errormsg: "invalid indentation" 6 | """ -------------------------------------------------------------------------------- /tests/pragmas/tonoff1.nim: -------------------------------------------------------------------------------- 1 | # issue #23002 2 | 3 | import monoff1 4 | 5 | proc test() = 6 | {.warning[ProveInit]: on.} 7 | 8 | test() 9 | -------------------------------------------------------------------------------- /tests/stdlib/mstrscans_undecl_scanf.nim: -------------------------------------------------------------------------------- 1 | import std/strscans 2 | 3 | proc scan*[T](s: string): (bool, string) = 4 | s.scanTuple("$+") 5 | -------------------------------------------------------------------------------- /tests/testdata/csvtest.csv: -------------------------------------------------------------------------------- 1 | headerField1,headerField2,headerField3 2 | 12,12132,"hallo "" 3 | du" 4 | 1,, 5 | ,2, 6 | ,,3 7 | 1,2,3 8 | 9 | -------------------------------------------------------------------------------- /tests/vm/tconstscope1.nim: -------------------------------------------------------------------------------- 1 | # issue #5395 2 | 3 | const a = (var b = 3; b) 4 | echo b #[tt.Error 5 | ^ undeclared identifier: 'b']# 6 | -------------------------------------------------------------------------------- /lib/nimrtl.nim.cfg: -------------------------------------------------------------------------------- 1 | # The RTL.dll needs to be compiled with these options! 2 | 3 | --app:lib 4 | --threads:on 5 | --define:createNimRtl 6 | 7 | -------------------------------------------------------------------------------- /tests/compiler/tgrammar.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "-d:nimTestGrammar" 3 | """ 4 | 5 | import compiler/parser 6 | 7 | checkSameGrammar() 8 | -------------------------------------------------------------------------------- /tests/destructor/t25341_aux/b.nim: -------------------------------------------------------------------------------- 1 | import ./module 2 | 3 | var globalObj: Distinct2[4] 4 | 5 | proc b*() = 6 | globalObj = make1[4]().make2() 7 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_2_2.nim: -------------------------------------------------------------------------------- 1 | 2 | import hotcodereloading 3 | 4 | proc f_2*(): int = return 1 5 | 6 | afterCodeReload: 7 | echo " 2: after!" 8 | -------------------------------------------------------------------------------- /tests/errmsgs/ttupleindexoutofbounds.nim: -------------------------------------------------------------------------------- 1 | let a = (1, 2)[4] #[tt.Error 2 | ^ invalid index 4 in subscript for tuple of length 2]# 3 | -------------------------------------------------------------------------------- /tests/js/t20233.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "yes" 3 | """ 4 | case 1.0 5 | of 1.0..2.0, 4.0: echo "yes" 6 | of 3.0: discard 7 | else: echo "no" -------------------------------------------------------------------------------- /tests/js/temptyseq.nim: -------------------------------------------------------------------------------- 1 | # #12671 2 | 3 | proc foo = 4 | var x: seq[int] 5 | doAssertRaises(IndexDefect): 6 | inc x[0] 7 | 8 | foo() 9 | -------------------------------------------------------------------------------- /tests/manyloc/keineschweine/server/nim.cfg: -------------------------------------------------------------------------------- 1 | debugger = off 2 | path = ".." 3 | path = "../genpacket" 4 | path = "../helpers" 5 | define = NoSFML 6 | -------------------------------------------------------------------------------- /tests/misc/m15955.nim: -------------------------------------------------------------------------------- 1 | proc add*(a, b: int): int {.cdecl, exportc.} = 2 | a + b 3 | proc sub*(a, b: int): int {.cdecl, exportc.} = 4 | a - b -------------------------------------------------------------------------------- /tests/modules/tincludeas.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Cannot use 'as' in 'include'." 3 | line: 6 4 | """ 5 | 6 | include foobar as foo 7 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter2/no_iterator.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch" 3 | line: 6 4 | """ 5 | 6 | for i in 5: 7 | echo i 8 | -------------------------------------------------------------------------------- /tests/parser/tdoublenotnil.nim: -------------------------------------------------------------------------------- 1 | when false: 2 | type Foo = Bar not nil not nil #[tt.Error 3 | ^ invalid indentation]# 4 | -------------------------------------------------------------------------------- /tests/sandwich/mdollar1.nim: -------------------------------------------------------------------------------- 1 | type Foo* = object 2 | x*, y*: int 3 | 4 | proc `$`*(f: Foo): string = 5 | "Foo(" & $f.x & ", " & $f.y & ")" 6 | -------------------------------------------------------------------------------- /tests/stdlib/tstrscans_undecl_scanf.nim: -------------------------------------------------------------------------------- 1 | import std/assertions 2 | import ./mstrscans_undecl_scanf 3 | doAssert scan[int]("foo") == (true, "foo") 4 | -------------------------------------------------------------------------------- /tests/tuples/ttypedesc_in_tuple_a.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "typedesc not allowed as tuple field." 3 | """ 4 | 5 | var bar = (a: int, b: 1) 6 | -------------------------------------------------------------------------------- /tests/vm/tnilref.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "attempt to access a nil address" 3 | """ 4 | 5 | static: 6 | var s: ref int 7 | s[] = 1 -------------------------------------------------------------------------------- /config/rename.rules.cfg: -------------------------------------------------------------------------------- 1 | TSignedInt 2 | TUnsignedInt 3 | TOrdinal 4 | TReal 5 | TNumber 6 | TEnum 7 | TObject 8 | TResult 9 | TOpenArray 10 | -------------------------------------------------------------------------------- /tests/align/globalalignas.nim: -------------------------------------------------------------------------------- 1 | var myglobal1* {.align(128).}: int32 2 | var myglobal2* {.align(128).}: int32 3 | var myglobal3* {.align(128).}: int32 4 | -------------------------------------------------------------------------------- /tests/enum/mcrossmodule.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | OtherEnum* = enum 4 | Success, Failed, More 5 | 6 | proc some*(x: OtherEnum): bool = x == Success 7 | -------------------------------------------------------------------------------- /tests/errmsgs/tassignunpack.nim: -------------------------------------------------------------------------------- 1 | var a, b = 0 2 | (a, b) = 1 #[tt.Error 3 | ^ tuple expected for tuple unpacking, but got 'int literal(1)']# 4 | -------------------------------------------------------------------------------- /tests/ic/mbaseobj.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | Base* = ref object of RootObj 4 | s*: string 5 | 6 | method m*(b: Base) {.base.} = 7 | echo "Base ", b.s 8 | -------------------------------------------------------------------------------- /tests/js/t21209.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | cmd: "nim check --warning[UnusedImport]:off $file" 4 | """ 5 | 6 | import std/times 7 | -------------------------------------------------------------------------------- /tests/lookups/mambsys1.nim: -------------------------------------------------------------------------------- 1 | import mambsys2 # import TExport 2 | 3 | type 4 | TExport* = enum x, y, z 5 | 6 | proc foo*(x: int) = 7 | discard 8 | -------------------------------------------------------------------------------- /tests/misc/mbetterrun.nim: -------------------------------------------------------------------------------- 1 | const mbetterrunVal {.strdefine.} = "" 2 | static: echo "compiling: " & mbetterrunVal 3 | echo "running: " & mbetterrunVal 4 | -------------------------------------------------------------------------------- /tests/misc/t23240.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c foo/bar.nim" 3 | action: "reject" 4 | errormsg: "cannot open 'foo/'" 5 | file: "" 6 | """ 7 | -------------------------------------------------------------------------------- /tests/misc/t6549.nim: -------------------------------------------------------------------------------- 1 | 2 | const l = $(range[low(uint64) .. high(uint64)]) 3 | const r = "range 0..18446744073709551615(uint64)" 4 | doAssert l == r 5 | -------------------------------------------------------------------------------- /tests/misc/tsamename2.nim: -------------------------------------------------------------------------------- 1 | proc fooBar*()=discard 2 | proc fooBar2*()=discard 3 | proc callFun*[Fun](processPattern: Fun) = 4 | processPattern() 5 | -------------------------------------------------------------------------------- /tests/modules/mexport2a.nim: -------------------------------------------------------------------------------- 1 | 2 | import mexport2b 3 | export mexport2b 4 | proc printAbc*() = echo "abc" 5 | 6 | proc foo*() = echo "A.foo" 7 | 8 | -------------------------------------------------------------------------------- /tests/stdlib/t21251.nim: -------------------------------------------------------------------------------- 1 | import std / [tables, sets, sharedtables] 2 | 3 | var shared: SharedTable[int, int] 4 | shared.init 5 | 6 | shared[1] = 1 7 | -------------------------------------------------------------------------------- /tests/system/tnewderef.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: 3 3 | 4 | """ 5 | 6 | var x: ref int 7 | new(x) 8 | x[] = 3 9 | 10 | echo x[] 11 | 12 | -------------------------------------------------------------------------------- /tests/template/tsighash_regression.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | exitcode: 1 3 | outputsub: "0" 4 | """ 5 | 6 | import tconfusinglocal 7 | 8 | fail "foo" 9 | -------------------------------------------------------------------------------- /tests/valgrind/tbasic_valgrind.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | valgrind: true 3 | cmd: "nim c --gc:destructors $file" 4 | """ 5 | 6 | echo "hello world" 7 | -------------------------------------------------------------------------------- /tests/vm/t19199.nim: -------------------------------------------------------------------------------- 1 | # bug #19199 2 | proc mikasa(x: float) = doAssert x == 42 3 | 4 | static: 5 | mikasa 42.uint.float 6 | mikasa 42.uint.float 7 | -------------------------------------------------------------------------------- /nimsuggest/tests/t20440.nim: -------------------------------------------------------------------------------- 1 | when not defined(js): 2 | {.fatal: "Crash".} 3 | echo 4 4 | 5 | discard """ 6 | $nimsuggest --v3 --tester $file 7 | """ 8 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tnimout.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: "Hello World!" 3 | action: compile 4 | """ 5 | 6 | static: 7 | echo "something else" 8 | -------------------------------------------------------------------------------- /tests/arc/t20456.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim check $file" 3 | action: "compile" 4 | """ 5 | 6 | when not defined(gcOrc): 7 | {.error: "orc".} 8 | -------------------------------------------------------------------------------- /tests/arc/tamodule.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | abcde 4 | 0 5 | ''' 6 | cmd: "nim c --gc:arc $file" 7 | """ 8 | 9 | import amodule 10 | -------------------------------------------------------------------------------- /tests/assert/t21195.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--verbosity:0 --os:standalone --mm:none" 3 | """ 4 | # bug #21195 5 | var n = 11 6 | assert(n == 12) 7 | -------------------------------------------------------------------------------- /tests/async/t21447.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "compile" 3 | cmd: "nim c -d:release -d:futureLogging $file" 4 | """ 5 | 6 | import std/asyncdispatch 7 | -------------------------------------------------------------------------------- /tests/cpp/t12946.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp" 3 | """ 4 | 5 | import std/atomics 6 | type Futex = distinct Atomic[int32] 7 | 8 | var x: Futex 9 | -------------------------------------------------------------------------------- /tests/cpp/tfam.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | """ 4 | type 5 | Test {.importcpp, header: "fam.h".} = object 6 | 7 | let test = newSeq[Test]() -------------------------------------------------------------------------------- /tests/errmsgs/temptysetparam.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot infer the type of parameter 'x'" 3 | line: 5 4 | """ 5 | proc a(x = {}) = discard 6 | -------------------------------------------------------------------------------- /tests/exception/t20613.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "; --panics:on" 3 | """ 4 | 5 | func test = 6 | if 0 > 10: 7 | raiseAssert "hey" 8 | test() 9 | -------------------------------------------------------------------------------- /tests/js/t7534.nim: -------------------------------------------------------------------------------- 1 | proc f(x: int): int = 2 | result = case x 3 | of 1: 2 4 | elif x == 2: 3 5 | else: 1 6 | 7 | doAssert 2 == f(f(f(f(1)))) 8 | -------------------------------------------------------------------------------- /tests/js/tmodify_cstring.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cstring doesn't support `[]=` operator" 3 | """ 4 | 5 | var x = cstring"abcd" 6 | x[0] = 'x' 7 | -------------------------------------------------------------------------------- /tests/nimdoc/readme.md: -------------------------------------------------------------------------------- 1 | ## links 2 | * $nim/nimdoc/tester.nim: tests html validation 3 | * $nim/tests/nimdoc/: tests `runnableExamples` + `nim doc` logic 4 | -------------------------------------------------------------------------------- /tests/objects/tillegal_recursion2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Cannot inherit from: 'Foo'" 3 | line: 6 4 | """ 5 | type 6 | Foo = object of Foo 7 | -------------------------------------------------------------------------------- /tests/pragmas/tcompile_missing_file.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | joinable: false 3 | errormsg: "cannot find: noexist.c" 4 | """ 5 | {.compile: "noexist.c".} 6 | -------------------------------------------------------------------------------- /tests/range/compilehelpers.nim: -------------------------------------------------------------------------------- 1 | template accept(e) = 2 | static: assert(compiles(e)) 3 | 4 | template reject(e) = 5 | static: assert(not compiles(e)) 6 | -------------------------------------------------------------------------------- /tests/system/tgcnone.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:none -d:useMalloc" 3 | """ 4 | # bug #15617 5 | # bug #22262 6 | let x = 4 7 | doAssert x == 4 8 | -------------------------------------------------------------------------------- /tests/tuples/ttypedesc_in_tuple_b.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Mixing types and values in tuples is not allowed." 3 | """ 4 | 5 | var bar = (int, 1) 6 | -------------------------------------------------------------------------------- /tests/types/t6456.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type \'ptr void\' is not allowed" 3 | line: 6 4 | """ 5 | 6 | proc foo(x: ptr void) = 7 | discard 8 | -------------------------------------------------------------------------------- /tests/vm/tconstscope2.nim: -------------------------------------------------------------------------------- 1 | const 2 | a = (var x = 3; x) 3 | # should we allow this? 4 | b = x #[tt.Error 5 | ^ undeclared identifier: 'x']# 6 | -------------------------------------------------------------------------------- /nimdoc/test_out_index_dot_html/expected/foo.idx: -------------------------------------------------------------------------------- 1 | nimTitle foo index.html module nimdoc/test_out_index_dot_html/foo 0 2 | nim foo index.html#foo proc foo() 1 3 | -------------------------------------------------------------------------------- /tests/ccgbugs/t21995.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp" 3 | output: "Hi!" 4 | """ 5 | 6 | try: 7 | raise 8 | except ReraiseDefect: 9 | echo "Hi!" -------------------------------------------------------------------------------- /tests/concepts/ttrieconcept.nim: -------------------------------------------------------------------------------- 1 | import libs/[trie_database, trie] 2 | 3 | proc takeDb(d: TrieDatabase) = discard 4 | var mdb: MemDB 5 | 6 | takeDb(mdb) 7 | 8 | -------------------------------------------------------------------------------- /tests/destructor/t25341.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --mm:orc $file" 3 | output: "" 4 | """ 5 | import ./t25341_aux/a, ./t25341_aux/b 6 | a() 7 | b() 8 | -------------------------------------------------------------------------------- /tests/enum/tenumitems.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "attempting to call routine: 'items'" 3 | line: 7 4 | """ 5 | 6 | type a = enum b,c,d 7 | a.items() 8 | -------------------------------------------------------------------------------- /tests/generics/t18823.nim: -------------------------------------------------------------------------------- 1 | type BitsRange[T] = range[0..sizeof(T)*8-1] 2 | 3 | proc bar[T](a: T; b: BitsRange[T]) = 4 | discard 5 | 6 | bar(1, 2.Natural) 7 | -------------------------------------------------------------------------------- /tests/generics/t8270.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot instantiate: \'T\'" 3 | line: 6 4 | """ 5 | 6 | proc m[T](x: T): int = discard 7 | echo [m] 8 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter2/no_seq_type.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot infer the type of the sequence" 3 | line: 6 4 | """ 5 | 6 | var list = @[] 7 | -------------------------------------------------------------------------------- /tests/objects/tillegal_recursion3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Cannot inherit from: 'Foo'" 3 | line: 6 4 | """ 5 | type 6 | Foo = object of ref Foo 7 | -------------------------------------------------------------------------------- /tests/stylecheck/t20397_2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'a_b' should be: 'aB'" 3 | matrix: "--styleCheck:error" 4 | """ 5 | 6 | var a_b = 1 7 | discard a_b -------------------------------------------------------------------------------- /tests/types/tforwty.nim: -------------------------------------------------------------------------------- 1 | # Test 13: forward types 2 | 3 | type 4 | PSym = ref TSym 5 | 6 | TSym = object 7 | next: PSym 8 | 9 | var s: PSym 10 | -------------------------------------------------------------------------------- /nimsuggest/tests/taccent_highlight.nim: -------------------------------------------------------------------------------- 1 | proc `$$$`#[!]# 2 | 3 | discard """ 4 | $nimsuggest --tester $file 5 | >highlight $1 6 | highlight;;skProc;;1;;6;;3 7 | """ 8 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tfile.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'undefined'" 3 | file: "notthisfile.nim" 4 | """ 5 | 6 | echo undefined 7 | -------------------------------------------------------------------------------- /tests/generics/m22373a.nim: -------------------------------------------------------------------------------- 1 | # module a for t22373 2 | 3 | # original: 4 | type LightClientHeader* = object 5 | 6 | # simplified: 7 | type TypeOrTemplate* = object 8 | -------------------------------------------------------------------------------- /tests/generics/t500.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | type 6 | TTest = tuple[x: range[0..80], y: range[0..25]] 7 | 8 | let x: TTest = (2, 23) 9 | -------------------------------------------------------------------------------- /tests/generics/tpragma.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: ''' 3 | in macro 4 | ''' 5 | """ 6 | 7 | # issue #18649 8 | 9 | import mpragma2 10 | p[string]() 11 | -------------------------------------------------------------------------------- /tests/global/t5958.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'a'" 3 | line: 9 4 | """ 5 | 6 | static: 7 | var a = 1 8 | 9 | echo a 10 | -------------------------------------------------------------------------------- /tests/js/t14570.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | 18 4 | ''' 5 | """ 6 | 7 | type A = range[15 .. 30] 8 | 9 | let a: A = 18 10 | 11 | echo ord(a) 12 | -------------------------------------------------------------------------------- /tests/lookups/mbind3.nim: -------------------------------------------------------------------------------- 1 | # Module A 2 | var 3 | lastId = 0 4 | 5 | template genId*: int = 6 | bind lastId 7 | inc(lastId) 8 | lastId 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/manyloc/named_argument_bug/tri_engine/config.nim: -------------------------------------------------------------------------------- 1 | when defined(doublePrecision): 2 | type 3 | TR* = float64 4 | else: 5 | type 6 | TR* = float32 7 | -------------------------------------------------------------------------------- /tests/misc/t21443.nim: -------------------------------------------------------------------------------- 1 | import std/envvars 2 | 3 | # bug #19292 4 | putEnv("NimPutEnvTest", "test") 5 | # bug #21122 6 | doAssert getEnv("NimPutEnvTest") == "test" 7 | -------------------------------------------------------------------------------- /tests/modules/mexportb.nim: -------------------------------------------------------------------------------- 1 | # module B 2 | type TMyObject* = object 3 | 4 | const xyz* = 13 5 | 6 | proc q*(x: int): int = 6 7 | proc q*(x: string): string = "8" 8 | -------------------------------------------------------------------------------- /tests/modules/tuppercased.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "hello" 3 | """ 4 | 5 | import UpperCased 6 | 7 | # stress normalization rules: 8 | echo Upper_Cased.str 9 | -------------------------------------------------------------------------------- /tests/parser/twrongcmdsyntax.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: '''in expression '4 2': identifier expected, but found '4''' 3 | line: 6 4 | """ 5 | 6 | echo 4 +2 7 | -------------------------------------------------------------------------------- /tests/sandwich/generic_library.nim: -------------------------------------------------------------------------------- 1 | 2 | proc libraryFunc*[T](x: T) = 3 | mixin mixedIn, indirectlyMixedIn 4 | echo mixedIn() 5 | echo indirectlyMixedIn() 6 | 7 | -------------------------------------------------------------------------------- /tests/sets/t2669.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot convert 6 to range 1..5(int8)" 3 | line: 6 4 | """ 5 | 6 | var c: set[range[1i8..5i8]] = {1i8, 2i8, 6i8} 7 | -------------------------------------------------------------------------------- /tests/sets/tnewsets.nim: -------------------------------------------------------------------------------- 1 | # new test for sets: 2 | 3 | const elem = ' ' 4 | 5 | var s: set[char] = {elem} 6 | assert(elem in s and 'a' not_in s and 'c' not_in s ) 7 | -------------------------------------------------------------------------------- /tests/system/tgogc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | disabled: "windows" 3 | cmd: "nim c --gc:go $file" 4 | action: "compile" 5 | """ 6 | # bug #11447 7 | echo "Go GC test" 8 | -------------------------------------------------------------------------------- /tests/tuples/tnimsconstunpack.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | cmd: "nim e $file" 4 | """ 5 | 6 | import mnimsconstunpack 7 | 8 | doAssert b == "b" 9 | -------------------------------------------------------------------------------- /tests/vm/tnilclosurecall.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "attempt to call nil closure" 3 | line: 8 4 | """ 5 | 6 | static: 7 | let x: proc () = nil 8 | x() 9 | -------------------------------------------------------------------------------- /lib/stdlib.nimble: -------------------------------------------------------------------------------- 1 | 2 | version = system.NimVersion 3 | author = "Dominik Picheta" 4 | description = "Nim's standard library." 5 | license = "MIT" 6 | -------------------------------------------------------------------------------- /nimsuggest/tests/tv3_import.nim: -------------------------------------------------------------------------------- 1 | import tv#[!]#3 2 | 3 | discard """ 4 | $nimsuggest --v3 --tester $file 5 | >def $1 6 | def skModule tv3 */tv3.nim 1 0 "" 100 7 | """ 8 | -------------------------------------------------------------------------------- /tests/concepts/tvarconcept.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "5" 3 | """ 4 | 5 | # bug #2346, bug #2404 6 | 7 | import mvarconcept 8 | 9 | echo randomInt(5) 10 | -------------------------------------------------------------------------------- /tests/dll/nimhcr_basic.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | Hello world 4 | ''' 5 | """ 6 | # for now orc only tests successful compilation 7 | 8 | echo "Hello world" 9 | -------------------------------------------------------------------------------- /tests/errmsgs/t10594.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expression has no address" 3 | line: 7 4 | """ 5 | 6 | template foo(v: varargs[int]) = addr v 7 | foo(1, 2) 8 | -------------------------------------------------------------------------------- /tests/errmsgs/t23419.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'void' in this context: '(array[0..-1, void],)' for var" 3 | """ 4 | 5 | var a: (array[0, void], ) 6 | -------------------------------------------------------------------------------- /tests/errmsgs/t6499.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'chr' is a built-in and cannot be used as a first-class procedure" 3 | """ 4 | 5 | # bug #6499 6 | let x = (chr, 0) 7 | -------------------------------------------------------------------------------- /tests/generics/mtypenodes.nim: -------------------------------------------------------------------------------- 1 | # issue #22699 2 | 3 | type Private = distinct int 4 | 5 | proc chop*[T](x: int): int = 6 | cast[int](cast[tuple[field: Private]](x)) 7 | -------------------------------------------------------------------------------- /tests/iter/titerslice.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''2 3 | 3 4 | 4''' 5 | """ 6 | 7 | var t1 = @["1", "2", "3", "4"] 8 | for t in t1[1..3]: 9 | echo t 10 | -------------------------------------------------------------------------------- /tests/lexer/tinvalidintegerliteral1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid number" 3 | file: "tinvalidintegerliteral1.nim" 4 | line: 7 5 | """ 6 | 7 | echo 0b 8 | -------------------------------------------------------------------------------- /tests/lexer/tinvalidintegerliteral2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid number" 3 | file: "tinvalidintegerliteral2.nim" 4 | line: 7 5 | """ 6 | 7 | echo 0x 8 | -------------------------------------------------------------------------------- /tests/macros/t7454.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expression has no type:" 3 | line: 8 4 | """ 5 | 6 | macro p(t: typedesc): typedesc = 7 | discard 8 | var a: p(int) 9 | -------------------------------------------------------------------------------- /tests/misc/tcharinc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "1" 3 | """ 4 | 5 | var c = '\0' 6 | while true: 7 | if c == '\xFF': break 8 | inc c 9 | 10 | echo "1" 11 | -------------------------------------------------------------------------------- /tests/modules/mopaque.nim: -------------------------------------------------------------------------------- 1 | type 2 | TLexer* {.final.} = object 3 | line*: int 4 | filename*: string 5 | buffer: cstring 6 | 7 | proc noProcVar*(): int = 18 8 | -------------------------------------------------------------------------------- /tests/parser/ttypecommandcomma.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | line: 8 4 | column: 19 5 | """ 6 | 7 | type 8 | Foo = call(1, 2), 3: 9 | 4 -------------------------------------------------------------------------------- /tests/proc/msugarcrash1.nim: -------------------------------------------------------------------------------- 1 | import std/options 2 | 3 | type 4 | Address* = object 5 | port*: int 6 | 7 | Node* = ref object 8 | address*: Option[Address] 9 | -------------------------------------------------------------------------------- /tests/proc/typed.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'typed' is only allowed in templates and macros" 3 | line: 6 4 | """ 5 | 6 | proc fun(x:typed)=discard 7 | fun(10) 8 | -------------------------------------------------------------------------------- /tests/system/tslimsystem.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "123" 3 | matrix: "-d:nimPreviewSlimSystem --mm:refc; -d:nimPreviewSlimSystem --mm:arc" 4 | """ 5 | 6 | echo 123 -------------------------------------------------------------------------------- /tests/tuples/t7012.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'Node'" 3 | """ 4 | 5 | type Node[T] = tuple 6 | next: ref Node[T] 7 | var n: Node[int] -------------------------------------------------------------------------------- /tests/types/tnontype.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expected type, but got: 3" 3 | """ 4 | 5 | type 6 | Foo = (block: 7 | int) 8 | 9 | Bar = 3 10 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tccodecheck.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | ccodecheck: "baz" 3 | """ 4 | 5 | proc foo(): void {.exportc: "bar".}= 6 | echo "Hello World" 7 | 8 | foo() 9 | -------------------------------------------------------------------------------- /tests/casestmt/trangeexhaustiveness.nim: -------------------------------------------------------------------------------- 1 | block: # issue #22661 2 | template foo(a: typed) = 3 | a 4 | 5 | foo: 6 | case false 7 | of false..true: discard 8 | -------------------------------------------------------------------------------- /tests/ccgbugs/tuplecast.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #4345 3 | 4 | # only needs to compile 5 | proc f(): tuple[a, b: uint8] = (1'u8, 2'u8) 6 | 7 | let a, b = f() 8 | let c = cast[int](b) 9 | -------------------------------------------------------------------------------- /tests/ccgbugs/xseq9578.nim: -------------------------------------------------------------------------------- 1 | import t9578 2 | 3 | proc testSeq*(x: var seq[mytype]) = 4 | f(x[0].addr) 5 | 6 | proc testSeq2*(x: var ptr seq[mytype]) = 7 | f(x[0].addr) 8 | -------------------------------------------------------------------------------- /tests/converter/tvargenericconverter.nim: -------------------------------------------------------------------------------- 1 | # regression test 2 | 3 | converter toPtr[T](x: var T): ptr T = 4 | result = addr x 5 | 6 | var x = 123 7 | let y: ptr int = x 8 | -------------------------------------------------------------------------------- /tests/js/t8821.nim: -------------------------------------------------------------------------------- 1 | 2 | proc isInt32(i: int): bool = 3 | case i 4 | of 1 .. 70000: 5 | return true 6 | else: 7 | return false 8 | 9 | doAssert isInt32(1) == true -------------------------------------------------------------------------------- /tests/manyloc/keineschweine/server/dirserver_settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "network":"lamenet", 3 | "port":2049, 4 | "zones":[ 5 | {"name":"alphazone","key":"skittles"} 6 | ] 7 | } -------------------------------------------------------------------------------- /tests/misc/tnolen.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | line: 8 4 | """ 5 | 6 | # please finally disallow Len(3) 7 | 8 | echo len(3) 9 | -------------------------------------------------------------------------------- /tests/msgs/mspellsuggest.nim: -------------------------------------------------------------------------------- 1 | proc fooBar4*(a: int) = discard 2 | var fooBar9* = 0 3 | 4 | var fooCar* = 0 5 | type FooBar* = int 6 | type FooCar* = int 7 | type GooBa* = int 8 | -------------------------------------------------------------------------------- /tests/parser/tifextracolon.nim: -------------------------------------------------------------------------------- 1 | # issue #21982 2 | 3 | if true: 4 | if true: 5 | discard default int: 6 | else: #[tt.Error 7 | ^ invalid indentation]# 8 | discard 9 | -------------------------------------------------------------------------------- /tests/sandwich/tmain.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''100 3 | 200''' 4 | """ 5 | 6 | import 7 | module_using_generic_library 8 | 9 | makeUseOfLibrary "test" 10 | -------------------------------------------------------------------------------- /tests/system/timmutableinc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | file: "timmutableinc.nim" 4 | line: 8 5 | """ 6 | var x = 0 7 | 8 | inc(x+1) 9 | -------------------------------------------------------------------------------- /tests/system/treprconverter.nim: -------------------------------------------------------------------------------- 1 | # issue #24864 2 | 3 | type S = distinct uint16 4 | converter d(field: uint8 | uint16): S = discard 5 | discard (repr(0'u16), repr(0'u8)) 6 | -------------------------------------------------------------------------------- /tests/typerel/t8905.nim: -------------------------------------------------------------------------------- 1 | type 2 | Foo[T] = distinct seq[T] 3 | Bar[T] = object 4 | 5 | proc newFoo[T](): Foo[T] = Foo[T](newSeq[T]()) 6 | 7 | var x = newFoo[Bar[int]]() 8 | -------------------------------------------------------------------------------- /tests/arc/tinvalidenumtostr.nim: -------------------------------------------------------------------------------- 1 | # issue #24875 2 | 3 | type 4 | MyEnum = enum 5 | One = 1 6 | 7 | var x = cast[MyEnum](0) 8 | let s = $x 9 | doAssert s == "" 10 | -------------------------------------------------------------------------------- /tests/array/tidx_lit_err2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expected ordinal value for array index, got '\"string\"'" 3 | line: 5 4 | """ 5 | let x = ["string": 0, "index": 1] 6 | -------------------------------------------------------------------------------- /tests/converter/tdontleak.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''5''' 3 | joinable: false 4 | """ 5 | 6 | import mdontleak 7 | # bug #19213 8 | 9 | let a = 5'u32 10 | echo a 11 | -------------------------------------------------------------------------------- /tests/errmsgs/t22996.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'typedesc[string]' for const" 3 | """ 4 | 5 | # bug #22996 6 | type MyObject = ref object 7 | _ = string 8 | -------------------------------------------------------------------------------- /tests/errmsgs/tkeywordparam.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'type' is a keyword and cannot be used as a parameter name" 3 | """ 4 | 5 | proc myproc(type: int) = 6 | echo type 7 | -------------------------------------------------------------------------------- /tests/errmsgs/tuncheckedarrayvar.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: ''' 3 | invalid type: 'UncheckedArray[uint8]' for var 4 | ''' 5 | """ 6 | 7 | var byteUA: UncheckedArray[uint8] 8 | -------------------------------------------------------------------------------- /tests/importalls/m3.nim: -------------------------------------------------------------------------------- 1 | # xxx use below naming convention in other test files: p: public, h: hidden 2 | const m3p1* = 2 3 | const m3h2 = 2 4 | const m3h3 = 3 5 | const m3h4 = 4 6 | -------------------------------------------------------------------------------- /tests/int/twrongvarconv.nim: -------------------------------------------------------------------------------- 1 | proc `++`(n: var int) = 2 | n += 1 3 | 4 | var a: int32 = 15 5 | 6 | ++a #[tt.Error 7 | ^ type mismatch: got ]# 8 | 9 | echo a 10 | -------------------------------------------------------------------------------- /tests/iter/ttypeofclosureiter.nim: -------------------------------------------------------------------------------- 1 | # issue #24859 2 | 3 | template u(): int = 4 | yield 0 5 | 0 6 | iterator s(): int {.closure.} = discard default(typeof(u())) 7 | let _ = s 8 | -------------------------------------------------------------------------------- /tests/lookups/tdisambsym.nim: -------------------------------------------------------------------------------- 1 | # issue #15247 2 | 3 | import mdisambsym1, mdisambsym2, mdisambsym3 4 | 5 | proc twice(n: int): int = 6 | n*2 7 | 8 | doAssert twice(count) == 20 9 | -------------------------------------------------------------------------------- /tests/misc/tjoinable.nim: -------------------------------------------------------------------------------- 1 | # checks that megatest allows duplicate names, see also `tests/testament/tjoinable.nim` 2 | doAssert defined(testing) 3 | doAssert defined(nimMegatest) 4 | -------------------------------------------------------------------------------- /tests/objects/trefobjfieldoverload.nim: -------------------------------------------------------------------------------- 1 | block: # issue #24492 2 | type MyType = ref object 3 | a: int 4 | 5 | proc a(val: MyType, i: int) = discard 6 | MyType().a(100) 7 | -------------------------------------------------------------------------------- /tests/package/tstdlib_name_not_special.nim: -------------------------------------------------------------------------------- 1 | # Test whether a another package named 'stdlib' can be imported and used. 2 | # This caused a crash in the past. 3 | import stdlib/system -------------------------------------------------------------------------------- /tests/parser/tifexprs.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | 1 4 | ''' 5 | """ 6 | 7 | var a, b: int 8 | let x = if a > b: 9 | 0 10 | else: 1 11 | 12 | echo x 13 | -------------------------------------------------------------------------------- /tests/sandwich/tstatic.nim: -------------------------------------------------------------------------------- 1 | from mstatic import Foo 2 | 3 | doAssert $Foo(x: 1, y: 2) == "static Foo(1, 2)" 4 | let foo = Foo(x: 3, y: 4) 5 | doAssert $foo == "runtime Foo(3, 4)" 6 | -------------------------------------------------------------------------------- /tests/sets/t13764.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "conversion from int literal(1000000) to range 0..255(int) is invalid" 3 | line: 6 4 | """ 5 | 6 | let a = {1_000_000} # Compiles 7 | -------------------------------------------------------------------------------- /tests/system/tatomics1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp js" 3 | """ 4 | 5 | var x = 10 6 | atomicInc(x) 7 | doAssert x == 11 8 | atomicDec(x) 9 | doAssert x == 10 10 | -------------------------------------------------------------------------------- /tests/system/tgcregions.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:regions $file" 3 | """ 4 | 5 | # issue #12597 6 | # it just tests that --gc:regions compiles. Nothing else. :'( 7 | -------------------------------------------------------------------------------- /tests/testament/t16576.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix:"-d:nimTest_t16576" 3 | """ 4 | 5 | # bug #16576 6 | doAssert defined(nimTest_t16576) 7 | doAssert not defined(nimMegatest) 8 | -------------------------------------------------------------------------------- /tests/typerel/tsigmatch.nim: -------------------------------------------------------------------------------- 1 | block: # bug #13618 2 | proc test(x: Natural or BackwardsIndex): int = 3 | int(x) 4 | 5 | doAssert test(^1) == 1 6 | doAssert test(1) == 1 7 | -------------------------------------------------------------------------------- /tests/typerel/ttypelessemptyset.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "statement returns no value that can be discarded" 3 | """ 4 | var q = false 5 | discard (if q: {} else: {}) 6 | 7 | -------------------------------------------------------------------------------- /tests/types/tillegalseqrecursion.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'CyclicSeq'" 3 | """ 4 | # issue #13715 5 | type 6 | CyclicSeq = seq[ref CyclicSeq] 7 | -------------------------------------------------------------------------------- /tests/views/tcan_compile_nim.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim check --hints:on --experimental:strictFuncs --experimental:views compiler/nim.nim" 3 | action: "compile" 4 | """ 5 | -------------------------------------------------------------------------------- /tests/vm/tscriptcompiletime.nims: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim e $file" 3 | """ 4 | 5 | import mscriptcompiletime 6 | 7 | macro foo = 8 | doAssert bar == 2 9 | foo() 10 | -------------------------------------------------------------------------------- /nimsuggest/tests/tdef_let.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | $nimsuggest --tester $file 3 | >def $1 4 | def;;skLet;;tdef_let.intVar;;int;;$file;;7;;4;;"";;100 5 | """ 6 | 7 | let int#[!]#Var = 10 8 | -------------------------------------------------------------------------------- /tests/ccgbugs/pkg8616/scheduler.nim: -------------------------------------------------------------------------------- 1 | import rtarray 2 | 3 | type 4 | T = tuple[x:int] 5 | 6 | var 7 | arr: array[1,T] 8 | 9 | proc init*() = 10 | discard head(arr) 11 | -------------------------------------------------------------------------------- /tests/ccgbugs/thtiobj.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:refc" 3 | targets: "c cpp" 4 | """ 5 | 6 | import typeinfo 7 | 8 | var x = "" 9 | discard (getPointer(toAny(x))) 10 | -------------------------------------------------------------------------------- /tests/ccgbugs/tsequence_outoforder.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''@[2]''' 3 | """ 4 | 5 | # bug #9684 6 | 7 | var s2 = @[2, 2] 8 | 9 | s2 = @[s2.len] 10 | 11 | echo s2 12 | -------------------------------------------------------------------------------- /tests/destructor/objFile.nim: -------------------------------------------------------------------------------- 1 | type Obj* = object 2 | v*: int 3 | 4 | proc `=destroy`(this: var Obj) = 5 | echo "igotdestroyed" 6 | this.v = -1 7 | 8 | var test* = Obj(v: 42) 9 | -------------------------------------------------------------------------------- /tests/errmsgs/t25120.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "request to generate code for .compileTime proc: riesig" 3 | """ 4 | 5 | proc riesig(): NimNode = discard 6 | discard riesig() 7 | -------------------------------------------------------------------------------- /tests/exception/t22008.nim: -------------------------------------------------------------------------------- 1 | template detect(v: untyped) = 2 | doAssert typeof(v) is int 3 | 4 | detect: 5 | try: 6 | raise (ref ValueError)() 7 | except ValueError: 8 | 42 -------------------------------------------------------------------------------- /tests/js/t7109.nim: -------------------------------------------------------------------------------- 1 | iterator iter*(): int {.closure.} = 2 | yield 3 3 | 4 | var x = iter 5 | doAssert x() == 3 6 | 7 | let fIt = iterator(): int = yield 70 8 | doAssert fIt() == 70 9 | -------------------------------------------------------------------------------- /tests/js/t8914.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | @[42] 4 | @[24, 42] 5 | ''' 6 | """ 7 | 8 | var x = @[42,4242] 9 | x.delete(1) 10 | echo x 11 | x.insert(24) 12 | echo x 13 | -------------------------------------------------------------------------------- /tests/manyloc/standalone2/tavr.nim: -------------------------------------------------------------------------------- 1 | # bug #16404 2 | 3 | proc printf(frmt: cstring) {.varargs, header: "", cdecl.} 4 | 5 | var x = 0 6 | inc x 7 | printf("hi %ld\n", x+4777) 8 | -------------------------------------------------------------------------------- /tests/metatype/typedesc_as_value.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'typedesc[int]' for var" 3 | """ 4 | 5 | 6 | var x = int 7 | 8 | echo x 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/modules/torder_dep.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''[0, 0]''' 3 | """ 4 | 5 | import morder_depb 6 | import morder_depa 7 | 8 | # bug #11187 9 | 10 | echo Foo(3) 11 | -------------------------------------------------------------------------------- /tests/nimdoc/sub/mmain.nim: -------------------------------------------------------------------------------- 1 | {.warning[UnusedImport]: off.} 2 | 3 | import ../imp as impa 4 | import imp as impb 5 | import imp2 6 | 7 | proc fn1*() = discard 8 | proc fn2*() = discard 9 | -------------------------------------------------------------------------------- /tests/objects/tillegal_recursion.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Cannot inherit from: 'Foo:ObjectType'" 3 | line: 7 4 | """ 5 | # bug #1691 6 | type 7 | Foo = ref object of Foo 8 | -------------------------------------------------------------------------------- /tests/overload/t7416.nim: -------------------------------------------------------------------------------- 1 | type 2 | Foo[T] = object 3 | IntFoo = Foo[int] 4 | 5 | proc bar(b: object|tuple) = discard 6 | proc bar(b: IntFoo) = discard 7 | 8 | var f: IntFoo 9 | bar(f) -------------------------------------------------------------------------------- /tests/parser/tstmtlistexprindent.nim: -------------------------------------------------------------------------------- 1 | type E = enum A, B, C 2 | proc junk(e: E) = 3 | case e 4 | of A: (echo "a"; 5 | discard; discard; 6 | discard) 7 | else: discard 8 | -------------------------------------------------------------------------------- /tests/parser/ttypecommandindent1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | line: 9 4 | column: 3 5 | """ 6 | 7 | type 8 | Foo = call x, y, z: 9 | abc 10 | -------------------------------------------------------------------------------- /tests/pragmas/t4384.nim: -------------------------------------------------------------------------------- 1 | macro testMacro(body: untyped): untyped = discard 2 | macro testMacro(s: string, body: untyped): untyped = discard 3 | proc foo() {.testMacro: "foo".} = discard 4 | -------------------------------------------------------------------------------- /tests/stdlib/osproctest.nim: -------------------------------------------------------------------------------- 1 | # This is test program for the osproc module. 2 | 3 | import os 4 | 5 | echo getCurrentDir() 6 | 7 | for i in 1..paramCount(): 8 | echo paramStr(i) 9 | -------------------------------------------------------------------------------- /tests/stdlib/toserrors.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | import std/oserrors 6 | 7 | let x1 = osLastError() 8 | raiseOSError(x1) 9 | echo osErrorMsg(x1) 10 | -------------------------------------------------------------------------------- /tests/stdlib/tterminal.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | import terminal, colors 5 | 6 | styledEcho fgColor, colRed, "Test" 7 | styledEcho bgColor, colBlue, "Test" 8 | -------------------------------------------------------------------------------- /tests/stmt/tforloop_underscore.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "the special identifier '_' is ignored in declarations and cannot be used" 3 | """ 4 | 5 | for _ in ["a"]: 6 | echo _ 7 | -------------------------------------------------------------------------------- /tests/typerel/tno_int_in_bool_context.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'bool'" 3 | line: 6 4 | """ 5 | 6 | if 1: 7 | echo "wtf?" 8 | -------------------------------------------------------------------------------- /tests/typerel/tptrs.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'ptr int'" 3 | line: 8 4 | """ 5 | 6 | var 7 | n: int16 8 | p: ptr int = addr n 9 | -------------------------------------------------------------------------------- /tests/align/tillegalalign.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim check $options $file" 3 | errormsg: "power of two expected" 4 | """ 5 | 6 | proc foobar() = 7 | let something {.align(33).} = 123 8 | -------------------------------------------------------------------------------- /tests/ccgbugs/mstatic_assert.nim: -------------------------------------------------------------------------------- 1 | {.emit:""" 2 | NIM_STATIC_ASSERT(sizeof(bool) == 1, ""); 3 | #warning "foo2" 4 | NIM_STATIC_ASSERT(sizeof(bool) == 2, ""); 5 | #warning "foo3" 6 | """.} 7 | -------------------------------------------------------------------------------- /tests/ccgbugs/xarray9578.nim: -------------------------------------------------------------------------------- 1 | import t9578 2 | 3 | proc testArray*(x: var array[3,mytype]) = 4 | f(x[0].addr) 5 | 6 | proc testArray2*(x: var ptr array[3,mytype]) = 7 | f(x[0].addr) 8 | -------------------------------------------------------------------------------- /tests/enum/tenum_invalid.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim check $file" 3 | """ 4 | 5 | type 6 | Test = enum 7 | A = 9.0 #[tt.Error 8 | ^ ordinal type expected; given: float]# 9 | -------------------------------------------------------------------------------- /tests/enum/toverloadedname.nim: -------------------------------------------------------------------------------- 1 | block: # issue #23998 2 | type 3 | Enum {.pure.} = enum 4 | a 5 | Obj = object 6 | a: Enum 7 | proc test(a: Enum) = discard Obj(a: a) 8 | -------------------------------------------------------------------------------- /tests/errmsgs/tconsttypemismatch.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch" 3 | file: "tconsttypemismatch.nim" 4 | line: 7 5 | """ 6 | # bug #2252 7 | const foo: int = 1000 / 30 8 | -------------------------------------------------------------------------------- /tests/modules/a/module_name_clashes.nim: -------------------------------------------------------------------------------- 1 | # See `tmodule_name_clashes` 2 | 3 | import ../b/module_name_clashes 4 | type A* = object 5 | b*: B 6 | 7 | proc print*(a: A) = 8 | echo repr a 9 | -------------------------------------------------------------------------------- /tests/modules/mexporta.nim: -------------------------------------------------------------------------------- 1 | # module A 2 | import mexportb 3 | export mexportb.TMyObject, mexportb.xyz 4 | 5 | export mexportb.q 6 | 7 | proc `$`*(x: TMyObject): string = "my object" 8 | 9 | -------------------------------------------------------------------------------- /tests/modules/texplicit_system_import.nim: -------------------------------------------------------------------------------- 1 | import system except `+` 2 | 3 | discard """ 4 | errormsg: "undeclared identifier: '+'" 5 | line: 9 6 | """ 7 | 8 | 9 | echo 4+5 10 | -------------------------------------------------------------------------------- /tests/parser/tbinarynotsameline.nim: -------------------------------------------------------------------------------- 1 | # issue #23565 2 | 3 | func foo: bool = 4 | true 5 | 6 | const bar = block: 7 | type T = int 8 | not foo() 9 | 10 | doAssert not bar 11 | -------------------------------------------------------------------------------- /tests/sandwich/tfilehandles.nim: -------------------------------------------------------------------------------- 1 | # issue #16755 2 | 3 | import mfiles 4 | from mhandles import FD 5 | #import handles <- do this and it works 6 | 7 | let wr = newFile(FD -1) 8 | close wr 9 | -------------------------------------------------------------------------------- /tests/stdlib/tintsets.nim: -------------------------------------------------------------------------------- 1 | import ./mintsets 2 | 3 | block: # bug https://github.com/nim-lang/Nim/pull/15564#issuecomment-729878104 4 | # related to bug #11167 5 | test1() 6 | test2() 7 | -------------------------------------------------------------------------------- /tests/stdlib/tterminal_15874.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --app:console $file" 3 | action: "compile" 4 | """ 5 | 6 | import terminal 7 | 8 | writeStyled("hello", {styleBright}) 9 | -------------------------------------------------------------------------------- /tests/testament/treject.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "reject" 3 | """ 4 | 5 | # this line does not compile, so the test should pass, since action="reject" 6 | let x: int = "type mismatch" 7 | -------------------------------------------------------------------------------- /tests/types/t21027.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Invalid usage of cast, cast requires a type to convert to, e.g., cast[int](0d)." 3 | """ 4 | # bug #21027 5 | let x: uint64 = cast(5) 6 | -------------------------------------------------------------------------------- /tests/types/texportgeneric.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "{.exportc.} not allowed for generic types" 3 | line: 6 4 | """ 5 | 6 | type Struct[T] {.exportc.} = object 7 | a:int 8 | b: T -------------------------------------------------------------------------------- /tests/types/tinfiniterecursion.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'XIM'" 3 | line: 8 4 | """ 5 | 6 | type 7 | XIM* = ptr XIM 8 | XIMProc* = proc (a2: XIM) 9 | -------------------------------------------------------------------------------- /nimdoc/extlinks/project/expected/_._/util.idx: -------------------------------------------------------------------------------- 1 | nimTitle util _._/util.html module nimdoc/extlinks/util 0 2 | nim utilfunction _._/util.html#utilfunction,int proc utilfunction(x: int): int 1 3 | -------------------------------------------------------------------------------- /nimsuggest/tests/timport1.nim: -------------------------------------------------------------------------------- 1 | import bito#[!]# 2 | 3 | discard """ 4 | $nimsuggest --tester --v4 --maxresults:1 $file 5 | >sug $1 6 | sug;;skModule;;bitops;;;;bitops;;1;;0;;"";;100;;None 7 | """ -------------------------------------------------------------------------------- /tests/arc/t18971.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:arc $file" 3 | """ 4 | 5 | type MyObj = ref object 6 | 7 | var o = MyObj() 8 | proc x: var MyObj = o 9 | 10 | var o2 = x() 11 | -------------------------------------------------------------------------------- /tests/cpp/tembarrassing_generic_bug.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | cmd: "nim cpp --threads:on $file" 4 | """ 5 | 6 | # bug #5142 7 | 8 | var ci: Channel[int] 9 | ci.open 10 | -------------------------------------------------------------------------------- /tests/errmsgs/t22097.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | """ 4 | 5 | proc toUInt16(x: var uint16) = 6 | discard 7 | 8 | var x = uint8(1) 9 | toUInt16 x 10 | -------------------------------------------------------------------------------- /tests/errmsgs/tnnodeindex.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "index 5 not in 0 .. 2" 3 | line: 7 4 | """ 5 | import macros 6 | macro t(x: untyped): untyped = 7 | result = x[5] 8 | t([1, 2, 3]) 9 | -------------------------------------------------------------------------------- /tests/generics/t21760.nim: -------------------------------------------------------------------------------- 1 | import std/tables 2 | 3 | type Url = object 4 | 5 | proc myInit(_: type[Url], params = default(Table[string, string])): Url = 6 | discard 7 | 8 | discard myInit(Url) -------------------------------------------------------------------------------- /tests/generics/t22826.nim: -------------------------------------------------------------------------------- 1 | import std/tables 2 | 3 | var a: Table[string, float] 4 | 5 | type Value*[T] = object 6 | table: Table[string, Value[T]] 7 | 8 | discard toTable({"a": Value[float]()}) -------------------------------------------------------------------------------- /tests/generics/tbadgenericlambda.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "nested proc can have generic parameters only when" 3 | line: 6 4 | """ 5 | 6 | let x = proc (x, y: auto): auto = x + y 7 | 8 | -------------------------------------------------------------------------------- /tests/import/t21496.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "ambiguous identifier: 'm21496'" 3 | """ 4 | 5 | import fizz/m21496, buzz/m21496 6 | 7 | # bug #21496 8 | 9 | discard m21496.fb() 10 | -------------------------------------------------------------------------------- /tests/importalls/m4.nim: -------------------------------------------------------------------------------- 1 | import ./m3 {.all.} 2 | import ./m3 as m3b 3 | export m3b 4 | export m3h3 5 | export m3.m3h4 6 | 7 | import ./m2 {.all.} as m2b 8 | export m2b except bar3 9 | 10 | -------------------------------------------------------------------------------- /tests/js/tunion.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "`{.union.}` is not implemented for js backend." 3 | """ 4 | 5 | type Foo {.union.} = object 6 | as_bytes: array[8, int8] 7 | data: int64 8 | -------------------------------------------------------------------------------- /tests/lookups/tmoduleclash2.nim: -------------------------------------------------------------------------------- 1 | import std/heapqueue 2 | proc heapqueue(x: int) = discard 3 | let x: proc (x: int) = heapqueue 4 | let y: proc = heapqueue 5 | when false: 6 | let z = heapqueue 7 | -------------------------------------------------------------------------------- /tests/misc/tfib.nim: -------------------------------------------------------------------------------- 1 | 2 | iterator fibonacci(): int = 3 | var a = 0 4 | var b = 1 5 | while true: 6 | yield a 7 | var c = b 8 | b = a 9 | a = a + c 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/pragmas/tpushexperimental.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''0 1 3 | 1 2 4 | 2 3 5 | 0 1 6 | 1 2 7 | 2 3 8 | 3 5''' 9 | """ 10 | 11 | import mpushexperimental 12 | 13 | main(12) 14 | -------------------------------------------------------------------------------- /tests/refc/t24844.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:refc; --mm:arc" 3 | joinable: false 4 | """ 5 | 6 | import m24844 7 | 8 | u() 9 | 10 | type E = distinct int 11 | discard p[E]() -------------------------------------------------------------------------------- /tests/sandwich/msetiter1.nim: -------------------------------------------------------------------------------- 1 | import sets 2 | 3 | proc initH*[V]: HashSet[V] = 4 | result = initHashSet[V]() 5 | 6 | proc foo*[V](h: var HashSet[V], c: seq[V]) = 7 | h = h + c.toHashSet() 8 | -------------------------------------------------------------------------------- /tests/stdlib/t15663.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:arc $file" 3 | output: "Test" 4 | """ 5 | 6 | import std/widestrs 7 | 8 | let ws = newWideCString("Test") 9 | echo ws 10 | -------------------------------------------------------------------------------- /tests/stylecheck/t20397_1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--styleCheck:off --hint:Name:on" 3 | """ 4 | 5 | {.hintAsError[Name]:on.} 6 | var a_b = 1 7 | discard a_b 8 | {.hintAsError[Name]:off.} 9 | -------------------------------------------------------------------------------- /tests/template/tfielduse.nim: -------------------------------------------------------------------------------- 1 | # issue #24657 2 | 3 | proc g() {.error.} = discard 4 | 5 | type T = object 6 | g: int 7 | 8 | template B(): untyped = typeof(T.g) 9 | type _ = B() 10 | -------------------------------------------------------------------------------- /tests/typerel/ttypedesc_as_genericparam1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:refc" 3 | errormsg: "type mismatch: got " 4 | line: 7 5 | """ 6 | # bug #3079, #1146 7 | echo repr(int) -------------------------------------------------------------------------------- /tests/vm/tconststaticvar_wrong.nim: -------------------------------------------------------------------------------- 1 | proc test = 2 | const TEST = block: 3 | let i = 1 4 | const j = i + 1 #[tt.Error 5 | ^ cannot evaluate at compile time: i]# 6 | j 7 | -------------------------------------------------------------------------------- /tools/detect/timesize.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(void) { 6 | printf("%ld\n", sizeof(time_t)); 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /koch.nim.cfg: -------------------------------------------------------------------------------- 1 | -d:booting 2 | 3 | @if openbsd: 4 | # because openbsd getAppFilename was broken in v0.20.0 5 | # workaround see https://github.com/nim-lang/Nim/pull/14291 6 | --lib:lib 7 | @end 8 | -------------------------------------------------------------------------------- /tests/arc/t17173.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--gc:refc; --gc:arc" 3 | """ 4 | 5 | import std/strbasics 6 | 7 | 8 | var a = " vhellov " 9 | strip(a) 10 | doAssert a == "vhellov" 11 | -------------------------------------------------------------------------------- /tests/c/timportedsize.nim: -------------------------------------------------------------------------------- 1 | {.emit: """ 2 | typedef struct Foo { 3 | NI64 a; 4 | NI64 b; 5 | } Foo; 6 | """.} 7 | 8 | type Foo {.importc: "Foo", size: 16.} = object 9 | 10 | var x: Foo 11 | -------------------------------------------------------------------------------- /tests/ccgbugs/tcompile_time_var_at_runtime.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "1\n2\n2\n3" 3 | """ 4 | var a {.compileTime.} = 1 5 | 6 | echo a 7 | a = 2 8 | echo a 9 | echo a 10 | a = 3 11 | echo a -------------------------------------------------------------------------------- /tests/destructor/tglobaldestructor.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: '''nim c --gc:arc $file''' 3 | output: '''(v: 42) 4 | igotdestroyed''' 5 | """ 6 | 7 | import objFile 8 | 9 | echo test 10 | -------------------------------------------------------------------------------- /tests/discard/tillegaldiscard.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal discard" 3 | line: 9 4 | """ 5 | 6 | proc pop[T](arg: T): T = 7 | echo arg 8 | 9 | discard tillegaldiscard.pop 10 | -------------------------------------------------------------------------------- /tests/generics/t21742.nim: -------------------------------------------------------------------------------- 1 | type 2 | Foo[T] = object 3 | x:T 4 | Bar[T,R] = Foo[T] 5 | Baz = Bar[int,float] 6 | 7 | proc qux[T,R](x: Bar[T,R]) = discard 8 | 9 | var b:Baz 10 | b.qux() -------------------------------------------------------------------------------- /tests/generics/t7141.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot instantiate: \'T\'" 3 | line: 6 4 | """ 5 | 6 | proc foo[T](x: T) = 7 | discard 8 | 9 | var fun = if true: foo else: foo 10 | -------------------------------------------------------------------------------- /tests/global/tglobal2.nim: -------------------------------------------------------------------------------- 1 | # b.nim 2 | import a_module 3 | doAssert foo() == 0 4 | 5 | proc hello(x: type) = 6 | var s {.global.} = default(x) 7 | doAssert s == 0 8 | 9 | hello(int) 10 | -------------------------------------------------------------------------------- /tests/js/t20235.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "run" 3 | output: "0 4" 4 | """ 5 | 6 | proc main = 7 | var s = "" 8 | s.setLen(4) 9 | echo s[0].ord, " ", s.len 10 | 11 | main() 12 | -------------------------------------------------------------------------------- /tests/lookups/mambtype2.nim: -------------------------------------------------------------------------------- 1 | import ./mambtype1 2 | export mambtype1 3 | template K*(kind: static int): auto = typedesc[mambtype1.K] 4 | template B*(kind: static int): auto = typedesc[mambtype1.K] 5 | -------------------------------------------------------------------------------- /tests/lookups/t23172.nim: -------------------------------------------------------------------------------- 1 | import issue_23172/m23172 2 | 3 | type FooX = distinct Foo 4 | 5 | func `$`*(x: FooX): string = 6 | $m23172.Foo(x) 7 | 8 | var a: FooX 9 | doAssert $a == "X" 10 | -------------------------------------------------------------------------------- /tests/lookups/tmacroamb.nim: -------------------------------------------------------------------------------- 1 | # issue #12732 2 | 3 | import mmacroamb 4 | const s0 = currentPkgDir2 #[tt.Error 5 | ^ ambiguous identifier: 'currentPkgDir2' -- use one of the following:]# 6 | -------------------------------------------------------------------------------- /tests/macros/tmacroaspragma.nim: -------------------------------------------------------------------------------- 1 | import macros 2 | 3 | macro foo(x: untyped): untyped = 4 | echo treerepr(callsite()) 5 | result = newNimNode(nnkStmtList) 6 | 7 | proc zoo() {.foo.} = echo "hi" 8 | -------------------------------------------------------------------------------- /tests/misc/t16244.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | line: 9 4 | """ 5 | 6 | proc g(): auto = 1 7 | proc h(): auto = 1.0 8 | 9 | var a = g() + h() 10 | -------------------------------------------------------------------------------- /tests/modules/timport_in_config.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''hallo''' 3 | joinable: false 4 | """ 5 | 6 | # bug #9978, #9994 7 | var x: DefinedInB 8 | 9 | echo "hi".replace("i", "allo") 10 | -------------------------------------------------------------------------------- /tests/modules/tincludetemplate.nim: -------------------------------------------------------------------------------- 1 | # issue #12539 2 | 3 | template includePath(n: untyped) = include ../modules/n # But `include n` works 4 | includePath(mincludetemplate) 5 | doAssert foo == 123 6 | -------------------------------------------------------------------------------- /tests/modules/tmodule_same_proc.nim: -------------------------------------------------------------------------------- 1 | 2 | import mmodule_same_proc 3 | 4 | # importing baz causes the error not to trigger 5 | #import baz 6 | 7 | # bug #11188 8 | 9 | discard "foo".bar() 10 | -------------------------------------------------------------------------------- /tests/overflow/tdistinct_range.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "Error: unhandled exception: over- or underflow [OverflowDefect]" 3 | exitcode: "1" 4 | """ 5 | var x: distinct range[0..5] 6 | dec(x) -------------------------------------------------------------------------------- /tests/overflow/twronginference.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot convert 256 to int8" 3 | line: 9 4 | """ 5 | 6 | # issue #23177 7 | 8 | var x: int8 9 | x = 256 10 | echo x # 0 11 | -------------------------------------------------------------------------------- /tests/proc/tlambdapragma.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid pragma: exportc" 3 | """ 4 | 5 | let _ = proc () {.exportc.} = 6 | # this would previously cause a codegen error 7 | discard 8 | -------------------------------------------------------------------------------- /tests/refc/m24844.nim: -------------------------------------------------------------------------------- 1 | type 2 | S*[T] = ref object of RootObj 3 | k: string 4 | A*[T] = ref object of S[T] 5 | 6 | proc p*[T](): S[T] = S[T]() 7 | proc u*() = discard A[int]() 8 | discard A[int]() -------------------------------------------------------------------------------- /tests/sandwich/mdollar2.nim: -------------------------------------------------------------------------------- 1 | import mdollar1 2 | 3 | proc makeFoo*(x, y: int): Foo = 4 | Foo(x: x, y: y) 5 | 6 | proc useFoo*(f: Foo) = 7 | echo "used: ", f # directly calls `foo.$` from scope 8 | -------------------------------------------------------------------------------- /tests/template/t21532.nim: -------------------------------------------------------------------------------- 1 | 2 | template elementType(a: untyped): typedesc = 3 | typeof(block: (for ai in a: ai)) 4 | 5 | func fn[T](a: T) = 6 | doAssert elementType(a) is int 7 | 8 | @[1,2,3].fn -------------------------------------------------------------------------------- /tests/vm/tunsupportedintfloatcast.nim: -------------------------------------------------------------------------------- 1 | static: 2 | echo cast[int32](12.0) #[tt.Error 3 | ^ VM does not support 'cast' from tyFloat with size 8 to tyInt32 with size 4 due to different sizes]# 4 | -------------------------------------------------------------------------------- /tools/start.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM COLOR 0A 3 | chcp 65001 4 | SET NIMPATH=%~dp0\.. 5 | SET PATH=%NIMPATH%\bin;%NIMPATH%\dist\mingw\bin;%PATH% 6 | cd %NIMPATH% 7 | cmd 8 | 9 | 10 | -------------------------------------------------------------------------------- /nimsuggest/tests/fixtures/minclude_types.nim: -------------------------------------------------------------------------------- 1 | # types used by minclude_* (import or include), to find with def in include 2 | 3 | type 4 | Greet* = object 5 | greeting*: string 6 | subject*: string -------------------------------------------------------------------------------- /tests/avr/thello.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --compileOnly --os:standalone --exceptions:quirky -d:noSignalHandler -d:danger --threads:off $file" 3 | action: "compile" 4 | """ 5 | 6 | echo "hi" 7 | -------------------------------------------------------------------------------- /tests/ccgbugs/t10964.nim: -------------------------------------------------------------------------------- 1 | func test*(input: var openArray[int32], start: int = 0, fin: int = input.len - 1) = 2 | discard 3 | 4 | var someSeq = @[1'i32] 5 | 6 | test(someSeq) 7 | # bug with gcc 14 -------------------------------------------------------------------------------- /tests/ccgbugs/t7079.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: run 3 | targets: '''c js''' 4 | """ 5 | 6 | import math 7 | let x = -0.0 8 | doAssert classify(x) == fcNegZero 9 | doAssert classify(1 / -0.0) == fcNegInf -------------------------------------------------------------------------------- /tests/closure/tinvalidclosure4.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal capture 'v'" 3 | line: 7 4 | """ 5 | 6 | proc outer(v: int) = 7 | proc b {.nimcall.} = echo v 8 | b() 9 | outer(5) 10 | -------------------------------------------------------------------------------- /tests/concepts/conceptsv2_helper.nim: -------------------------------------------------------------------------------- 1 | type 2 | ShadowConcept* = concept 3 | proc iGetShadowed(s: Self) 4 | DummyFitsObj* = object 5 | 6 | proc iGetShadowed*(s: DummyFitsObj)= 7 | discard 8 | 9 | -------------------------------------------------------------------------------- /tests/converter/t18986.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "Found a 0" 3 | """ 4 | 5 | import m18986 except Lit 6 | import std/macros 7 | 8 | # bug #18986 9 | var x = 0.uint 10 | echo "Found a ", x 11 | -------------------------------------------------------------------------------- /tests/defer/t22309.nim: -------------------------------------------------------------------------------- 1 | block: 2 | defer: 3 | let a = 42 4 | doAssert not declared(a) 5 | 6 | proc lol() = 7 | defer: 8 | let a = 42 9 | doAssert not declared(a) 10 | 11 | lol() 12 | -------------------------------------------------------------------------------- /tests/enum/tenum_duplicate.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "duplicate value in enum 'd'" 3 | """ 4 | 5 | type 6 | unordered_enum = enum 7 | a = 1 8 | b = 0 9 | c 10 | d = 2 11 | -------------------------------------------------------------------------------- /tests/errmsgs/t8339.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'seq[float]'" 3 | line: 8 4 | """ 5 | 6 | import sequtils 7 | 8 | var x: seq[float] = @[1].mapIt(it) 9 | -------------------------------------------------------------------------------- /tests/exception/t21261.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | exitcode: 1 3 | outputsub: ''' 4 | m21261.nim(1) m21261 5 | Error: unhandled exception: something [Exception] 6 | ''' 7 | """ 8 | 9 | import m21261 -------------------------------------------------------------------------------- /tests/global/t21896.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot assign local to global variable" 3 | line: 7 4 | """ 5 | 6 | proc example(a:int) = 7 | let b {.global.} = a 8 | 9 | example(1) 10 | -------------------------------------------------------------------------------- /tests/lookups/tambsys.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "" 3 | """ 4 | # Test ambiguous symbols 5 | 6 | import mambsys1, mambsys2 7 | 8 | var 9 | v: mambsys1.TExport 10 | mambsys2.foo(3) #OUT 11 | -------------------------------------------------------------------------------- /tests/method/tmethod.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "\'method\' needs a parameter that has an object type" 3 | file: "tmethod.nim" 4 | line: 7 5 | """ 6 | 7 | method m(i: int): int = 8 | return 5 9 | -------------------------------------------------------------------------------- /tests/modules/timportexcept.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: '%'" 3 | line: 9 4 | """ 5 | 6 | import strutils except `%` 7 | 8 | # doesn't work 9 | echo "$1" % "abc" 10 | -------------------------------------------------------------------------------- /tests/modules/trecmod.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "recursive module dependency detected" 3 | file: "mrecmod.nim" 4 | line: 1 5 | disabled: true 6 | """ 7 | # recursive module 8 | import mrecmod 9 | -------------------------------------------------------------------------------- /tests/proc/t17157.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'untyped' is only allowed in templates and macros or magic procs" 3 | """ 4 | 5 | template something(op: proc (v: untyped): void): void = 6 | discard 7 | -------------------------------------------------------------------------------- /tests/stdlib/t21406.nim: -------------------------------------------------------------------------------- 1 | import std/[times, strformat] 2 | import std/assertions 3 | 4 | let aTime = getTime() 5 | doAssert fmt"{aTime}" == $aTime 6 | let aNow = now() 7 | doAssert fmt"{aNow}" == $aNow 8 | -------------------------------------------------------------------------------- /tests/vm/tconststaticvar3.nim: -------------------------------------------------------------------------------- 1 | # issue #24633 2 | 3 | import std/sequtils 4 | 5 | proc f(a: static openArray[int]) = 6 | const s1 = a.mapIt(it) 7 | const s2 = a.toSeq() 8 | 9 | f([1,2,3]) 10 | -------------------------------------------------------------------------------- /nimsuggest/tests/fixtures/mfakeassert.nim: -------------------------------------------------------------------------------- 1 | # Template for testing defs 2 | 3 | template fakeAssert*(cond: untyped, msg: string = "") = 4 | ## template to allow def lookup testing 5 | if not cond: quit(1) 6 | -------------------------------------------------------------------------------- /tests/array/tidx_lit_err3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "size of array exceeds range of index type 'range 2147483646..2147483647(int32)' by 1 elements" 3 | line: 5 4 | """ 5 | echo [high(int32)-1: 1, 2, 3] 6 | -------------------------------------------------------------------------------- /tests/ccgbugs/t19585.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp" 3 | """ 4 | 5 | # bug #19585 6 | 7 | type 8 | X* {.exportc.} = object 9 | v: int 10 | 11 | {.emit:""" 12 | X x = { 1234 }; 13 | """.} -------------------------------------------------------------------------------- /tests/ccgbugs/t5345.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: true 3 | """ 4 | 5 | proc cmpx(d: int): bool {.inline.} = d > 0 6 | 7 | proc abc[C](cx: C, d: int) = 8 | echo cx(d) 9 | 10 | abc(cmpx, 10) 11 | -------------------------------------------------------------------------------- /tests/errmsgs/t19882_2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot instantiate: 'A[T]'; the object's generic parameters cannot be inferred and must be explicitly given" 3 | """ 4 | type A[T] = object 5 | var a = A() -------------------------------------------------------------------------------- /tests/errmsgs/tnnodeadd.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot add to node kind: nnkInt8Lit" 3 | line: 7 4 | """ 5 | import macros 6 | macro t(x: untyped): untyped = 7 | x.add(newEmptyNode()) 8 | t(38'i8) 9 | -------------------------------------------------------------------------------- /tests/errmsgs/trecursiveproctype3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'MyFunc'" 3 | line: 9 4 | """ 5 | 6 | # issue #19271 7 | 8 | type 9 | MyFunc = proc(f: ptr MyFunc) 10 | -------------------------------------------------------------------------------- /tests/exprs/tstmtexp.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expression '5' is of type 'int literal(5)' and has to be used (or discarded)" 3 | file: "tstmtexp.nim" 4 | line: 8 5 | """ 6 | # Test 3 7 | 8 | 1+4 9 | -------------------------------------------------------------------------------- /tests/gc/tdisable_orc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | joinable: false 3 | retries: 2 4 | """ 5 | 6 | import std/asyncdispatch 7 | 8 | # bug #22256 9 | GC_disableMarkAndSweep() 10 | waitFor sleepAsync(1000) 11 | -------------------------------------------------------------------------------- /tests/generics/mfriends.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | TMyObj = object 4 | x: int 5 | 6 | proc gen*[T](): T = 7 | var d: TMyObj 8 | # access private field here 9 | d.x = 3 10 | result = d.x 11 | 12 | -------------------------------------------------------------------------------- /tests/generics/t14193.nim: -------------------------------------------------------------------------------- 1 | type 2 | Task*[N: int] = object # XXX this shouldn't work, should be `static int` 3 | env*: array[N, byte] 4 | 5 | var task14193: Task[20] 6 | doAssert task14193.env.len == 20 7 | -------------------------------------------------------------------------------- /tests/generics/tgenericbodyreturn1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot instantiate: 'T'" 3 | file: "system.nim" 4 | """ 5 | 6 | # issue #24091 7 | 8 | type M[V] = object 9 | echo default(M) 10 | -------------------------------------------------------------------------------- /tests/iter/titerautoerr3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot infer the return type of 'bar'" 3 | line: 6 4 | """ 5 | 6 | iterator bar(): auto = 7 | discard 8 | for t in bar(): 9 | discard 10 | -------------------------------------------------------------------------------- /tests/js/t11353.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | {} 4 | {} 5 | ''' 6 | """ 7 | 8 | proc foo() = 9 | var bar: set[int16] = {} 10 | echo bar 11 | bar.incl(1) 12 | 13 | foo() 14 | foo() 15 | -------------------------------------------------------------------------------- /tests/js/tjshello_stacktrace.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "Hello World" 3 | maxcodesize: 4500 4 | ccodecheck: "!@'function'" 5 | """ 6 | 7 | import jsconsole 8 | 9 | console.log "Hello World" 10 | -------------------------------------------------------------------------------- /tests/misc/tvcc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--cc:vcc" 3 | disabled: "linux" 4 | disabled: "bsd" 5 | disabled: "osx" 6 | disabled: "unix" 7 | disabled: "posix" 8 | """ 9 | doAssert true 10 | -------------------------------------------------------------------------------- /tests/openarray/t8259.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'openArray[int]' for result" 3 | line: 6 4 | """ 5 | 6 | proc foo(a: openArray[int]):auto = a 7 | echo foo(toOpenArray([1, 2], 0, 2)) 8 | -------------------------------------------------------------------------------- /tests/overload/tambiguousexplicitgeneric.nim: -------------------------------------------------------------------------------- 1 | # related to issue #8064 2 | 3 | import tables 4 | 5 | let x = values[int] #[tt.Error 6 | ^ ambiguous identifier: 'values' -- use one of the following:]# 7 | -------------------------------------------------------------------------------- /tests/sandwich/tsetiter2.nim: -------------------------------------------------------------------------------- 1 | # comment on issue #11167 2 | 3 | import msetiter2 4 | 5 | let x = dedupe([1, 2, 3]) 6 | doAssert x.len == 3 7 | doAssert 1 in x 8 | doAssert 2 in x 9 | doAssert 3 in x 10 | -------------------------------------------------------------------------------- /tests/stckovfl.nim: -------------------------------------------------------------------------------- 1 | # To test stack overflow message 2 | 3 | proc over(a: int): int = 4 | if a >= 10: 5 | assert false 6 | return 7 | result = over(a+1)+5 8 | 9 | Echo($over(0)) 10 | 11 | -------------------------------------------------------------------------------- /doc/overview.md: -------------------------------------------------------------------------------- 1 | ============================= 2 | Nim Documentation Overview 3 | ============================= 4 | 5 | :Author: Andreas Rumpf 6 | :Version: |nimversion| 7 | 8 | .. include:: docs.md 9 | 10 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/terrormsg.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "wrong error message" 3 | line: 9 4 | column: 6 5 | """ 6 | 7 | # test should fail because the line directive is wrong 8 | echo undeclared 9 | -------------------------------------------------------------------------------- /tests/array/tindexconv.nim: -------------------------------------------------------------------------------- 1 | block: # issue #17958 2 | var mem: array[uint8, uint8] 3 | let val = 0xffff'u16 4 | discard mem[uint8 val] # Error: unhandled exception: index 65535 not in 0 .. 255 [IndexDefect] 5 | -------------------------------------------------------------------------------- /tests/closure/t15594.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "The variable name cannot be `result`!" 3 | """ 4 | 5 | import sugar 6 | 7 | proc begin(): int = 8 | capture result: 9 | echo 1+1 10 | result 11 | -------------------------------------------------------------------------------- /tests/compiler/t12684.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim check --hints:off --warnings:off $file" 3 | errormsg: "undeclared identifier: 'Undeclared'" 4 | """ 5 | 6 | var x: Undeclared 7 | import compiler/nimeval 8 | -------------------------------------------------------------------------------- /tests/errmsgs/twrongdefinetype.nim: -------------------------------------------------------------------------------- 1 | # issue #24539 2 | 3 | type Foo = object 4 | const foo {.define.} = Foo() #[tt.Error 5 | ^ unsupported type for constant 'foo' with .define pragma: Foo]# 6 | echo repr(foo) 7 | -------------------------------------------------------------------------------- /tests/exprs/tresultwarning.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: "tresultwarning.nim(6, 7) Warning: Special variable 'result' is shadowed. [ResultShadowed]" 3 | """ 4 | 5 | proc test(): string = 6 | var result = "foo" 7 | -------------------------------------------------------------------------------- /tests/js/t12672.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "" 3 | """ 4 | 5 | proc foo = 6 | var x: seq[seq[int]] 7 | for row in x.mitems: 8 | let i = 1 9 | echo row 10 | inc row[i-1] 11 | 12 | foo() 13 | -------------------------------------------------------------------------------- /tests/modules/tnotuniquename.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''nested 3 | flat''' 4 | """ 5 | 6 | import mnotuniquename 7 | import tnotuniquename_dir/mnotuniquename as nun 8 | 9 | nested() 10 | flat() 11 | -------------------------------------------------------------------------------- /tests/niminaction/Chapter2/explicit_discard.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "has to be used (or discarded)" 3 | line: 7 4 | """ 5 | 6 | proc myProc(name: string): string = "Hello " & name 7 | myProc("Dominik") 8 | -------------------------------------------------------------------------------- /tests/parser/t12274.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | joinable: false 3 | """ 4 | 5 | var s: seq[int] 6 | s.add block: 7 | let i = 1 8 | i 9 | s.add try: 10 | 2 11 | except: 12 | 3 13 | doAssert s == @[1, 2] 14 | -------------------------------------------------------------------------------- /tests/stdlib/tstrtabs.nims: -------------------------------------------------------------------------------- 1 | import std/[strtabs, assertions] 2 | 3 | static: 4 | let t = {"name": "John", "city": "Monaco"}.newStringTable 5 | doAssert "${name} lives in ${city}" % t == "John lives in Monaco" 6 | -------------------------------------------------------------------------------- /tests/template/mcan_access_hidden_field.nim: -------------------------------------------------------------------------------- 1 | 2 | type 3 | Foo* = object 4 | fooa, foob: int 5 | 6 | proc createFoo*(a, b: int): Foo = Foo(fooa: a, foob: b) 7 | 8 | template geta*(f: Foo): untyped = f.fooa 9 | -------------------------------------------------------------------------------- /tests/vm/t17039.nim: -------------------------------------------------------------------------------- 1 | type 2 | Obj1 = object 3 | case kind: bool 4 | of false: 5 | field: seq[int] 6 | else: discard 7 | 8 | static: 9 | var obj1 = Obj1() 10 | obj1.field.add(@[]) 11 | -------------------------------------------------------------------------------- /tests/vm/tconststaticvar2.nim: -------------------------------------------------------------------------------- 1 | # issue #24634 2 | 3 | type J = object 4 | 5 | template m(u: J): int = 6 | let v = u 7 | 0 8 | 9 | proc g() = 10 | const x = J() 11 | const _ = m(x) 12 | 13 | g() 14 | -------------------------------------------------------------------------------- /tests/vm/tnocompiletimefunclambda.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "request to generate code for .compileTime proc: :anonymous" 3 | """ 4 | 5 | let a = func(a: varargs[int]) {.compileTime, closure.} = 6 | discard a[0] -------------------------------------------------------------------------------- /lib/system/formatfloat.nim: -------------------------------------------------------------------------------- 1 | when not defined(nimPreviewSlimSystem): 2 | import std/formatfloat 3 | export formatfloat 4 | {.deprecated: "use `std/formatfloat`".} 5 | else: 6 | {.error: "use `std/formatfloat`".} 7 | -------------------------------------------------------------------------------- /nimsuggest/tests/tsug_recursive.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | $nimsuggest --tester $file 3 | >sug $1 4 | sug;;skProc;;tsug_recursive.fooBar;;proc ();;$file;;7;;5;;"";;100;;Prefix 5 | """ 6 | 7 | proc fooBar() = 8 | fooBa#[!]# 9 | -------------------------------------------------------------------------------- /testament/lib/readme.md: -------------------------------------------------------------------------------- 1 | This directory contains helper files used by several tests, to avoid 2 | code duplication, akin to a std extension tailored for testament. 3 | 4 | Some of these could later migrate to stdlib. 5 | -------------------------------------------------------------------------------- /tests/ccgbugs/tcodegenbug_bool.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | """ 3 | 4 | # issue #13798 5 | {.emit:""" 6 | #include 7 | void fun(bool a){} 8 | """.} 9 | 10 | proc fun(a: bool) {.importc.} 11 | fun(true) 12 | -------------------------------------------------------------------------------- /tests/ccgbugs/topenarraycast.nim: -------------------------------------------------------------------------------- 1 | proc foo[T](s: var openArray[T]): T = 2 | for x in s: result += x 3 | 4 | proc bar(xyz: var seq[int]) = 5 | doAssert 6 == (seq[int](xyz)).foo() 6 | 7 | var t = @[1,2,3] 8 | bar(t) 9 | -------------------------------------------------------------------------------- /tests/ccgbugs/xua9578.nim: -------------------------------------------------------------------------------- 1 | import t9578 2 | 3 | proc testUncheckedArray*(x: var UncheckedArray[mytype]) = 4 | f(x[0].addr) 5 | 6 | proc testUncheckedArray2*(x: var ptr UncheckedArray[mytype]) = 7 | f(x[0].addr) 8 | -------------------------------------------------------------------------------- /tests/cpp/t23306.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | """ 4 | 5 | type K = object 6 | h: iterator(f: K): K 7 | 8 | iterator d(g: K): K {.closure.} = 9 | defer: 10 | discard 11 | 12 | discard K(h: d) -------------------------------------------------------------------------------- /tests/enum/tenum_self.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "1 can't be converted to ErrorFoo" 3 | """ 4 | 5 | 6 | type 7 | Foo = enum 8 | Bar = 0.Foo 9 | 10 | ErrorFoo = enum 11 | eBar = 1.ErrorFoo 12 | -------------------------------------------------------------------------------- /tests/enum/tenummix.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch" 3 | file: "tenummix.nim" 4 | line: 11 5 | """ 6 | 7 | type 8 | TE1 = enum eA, eB 9 | TE2 = enum eC, eD 10 | 11 | assert eA != eC 12 | -------------------------------------------------------------------------------- /tests/errmsgs/tcannot_capture_builtin.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'+' is a built-in and cannot be used as a first-class procedure" 3 | line: 8 4 | """ 5 | 6 | # bug #2050 7 | 8 | let v: proc (a, b: int): int = `+` 9 | -------------------------------------------------------------------------------- /tests/errmsgs/trecursiveproctype6.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'Test" 3 | line: 9 4 | """ 5 | 6 | # issue #18855 7 | 8 | type 9 | TestProc = proc(a: Test) 10 | Test = Test 11 | -------------------------------------------------------------------------------- /tests/js/t21439.nim: -------------------------------------------------------------------------------- 1 | proc test(a: openArray[string]): proc = 2 | let a = @a 3 | result = proc = 4 | for i in a: 5 | discard i 6 | 7 | 8 | const a = ["t1", "t2"] 9 | 10 | discard test(a) 11 | 12 | -------------------------------------------------------------------------------- /tests/macros/t15751.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --hints:off $file" 3 | nimout: "out" 4 | """ 5 | 6 | # bug #15751 7 | macro print(n: untyped): untyped = 8 | echo n.repr 9 | 10 | print: 11 | out 12 | -------------------------------------------------------------------------------- /tests/parser/tinvifstmt.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | line: 9 4 | column: 3 5 | """ 6 | 7 | if true: 8 | echo "a" 9 | elif: 10 | echo "b" 11 | else: 12 | echo "c" 13 | -------------------------------------------------------------------------------- /tests/parser/tstatementoperators.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: ''' 3 | Infix 4 | Ident "from" 5 | Ident "a" 6 | Ident "b" 7 | ''' 8 | """ 9 | 10 | from macros import dumpTree 11 | 12 | dumpTree(a from b) -------------------------------------------------------------------------------- /tests/parser/ttypecommandindent2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | line: 10 4 | column: 5 5 | """ 6 | 7 | type 8 | Foo = call x, y, z: 9 | abc 10 | do: 11 | def 12 | -------------------------------------------------------------------------------- /tests/pragmas/tsym_as_pragma.nim: -------------------------------------------------------------------------------- 1 | 2 | # bug #3171 3 | 4 | template newDataWindow(): untyped = 5 | let eventClosure = proc (closure: pointer): bool {.closure, cdecl.} = 6 | discard 7 | 8 | newDataWindow() 9 | -------------------------------------------------------------------------------- /tests/proc/tprocredef.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "redefinition of \'foo\'" 3 | file: "tprocredef.nim" 4 | line: 8 5 | """ 6 | 7 | proc foo(a: int, b: string) = discard 8 | proc foo(a: int, b: string) = discard 9 | -------------------------------------------------------------------------------- /tests/stmt/tgenericsunderscore.nim: -------------------------------------------------------------------------------- 1 | # issue #21435 2 | 3 | proc foo[_](x: typedesc[_]): string = "BAR" #[tt.Error 4 | ^ the special identifier '_' is ignored in declarations and cannot be used]# 5 | -------------------------------------------------------------------------------- /tests/tools/tctags2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: '''nim ctags $file''' 3 | action: "compile" 4 | """ 5 | 6 | type 7 | Foo = object 8 | 9 | proc hello() = discard 10 | 11 | proc `$`(x: Foo): string = "foo" 12 | -------------------------------------------------------------------------------- /tests/typerel/typredef.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type \'Uint8\'" 3 | file: "typredef.nim" 4 | line: 7 5 | """ 6 | type 7 | Uint8 = Uint8 #ERROR_MSG illegal recursion in type 'Uint8' 8 | -------------------------------------------------------------------------------- /tests/types/tillegaltuplerecursiongeneric2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'TPearl'" 3 | """ 4 | 5 | type 6 | TPearl[T] = tuple 7 | next: TPearl[T] 8 | 9 | var x: TPearl[int] 10 | -------------------------------------------------------------------------------- /tests/vm/tclosureiterator.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Closure iterators are not supported by VM!" 3 | """ 4 | 5 | iterator iter*(): int {.closure.} = 6 | yield 3 7 | 8 | static: 9 | var x = iter 10 | -------------------------------------------------------------------------------- /tests/vm/toverflowopcsubimmint.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "over- or underflow" 3 | """ 4 | 5 | static: 6 | proc p = 7 | var x = int64.low 8 | discard x - 1 9 | doAssert false 10 | p() 11 | -------------------------------------------------------------------------------- /tests/vm/twrongconst.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot evaluate at compile time: x" 3 | line: 7 4 | """ 5 | 6 | var x: array[100, char] 7 | template foo : char = x[42] 8 | 9 | const myConst = foo 10 | -------------------------------------------------------------------------------- /lib/deprecated/pure/future.nim: -------------------------------------------------------------------------------- 1 | ## This module is a deprecated alias for the `sugar` module. Deprecated since 0.19.0. 2 | 3 | {.deprecated: "Use the new 'sugar' module instead".} 4 | 5 | import std/sugar 6 | export sugar 7 | -------------------------------------------------------------------------------- /tests/c/tcompile.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''44''' 3 | joinable: "false" 4 | """ 5 | 6 | {.compile: "tcompile.c".} 7 | 8 | proc foo(a, b: cint): cint {.importc: "foo", cdecl.} 9 | 10 | echo foo(40, 4) 11 | -------------------------------------------------------------------------------- /tests/ccgbugs/t21116.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp" 3 | disabled: windows 4 | """ 5 | # bug #21116 6 | import std/os 7 | 8 | proc p(glob: string) = 9 | for _ in walkFiles(glob): discard 10 | p("dir/*") 11 | -------------------------------------------------------------------------------- /tests/ccgbugs/xtuple9578.nim: -------------------------------------------------------------------------------- 1 | import t9578 2 | 3 | proc testTuple*(x: var tuple[a:mytype,b:mytype,c:mytype]) = 4 | f(x[0].addr) 5 | 6 | proc testTuple2*(x: var ptr tuple[a:mytype,b:mytype,c:mytype]) = 7 | f(x[0].addr) 8 | -------------------------------------------------------------------------------- /tests/cpp/virtualptr.nim: -------------------------------------------------------------------------------- 1 | type 2 | Loo* {.exportc.} = object 3 | LooPtr* = ptr Loo 4 | Moo* {.exportc.} = object 5 | loo*: LooPtr 6 | 7 | 8 | proc salute*(foo: LooPtr) {.virtual.} = 9 | discard 10 | -------------------------------------------------------------------------------- /tests/errmsgs/t8064.nim: -------------------------------------------------------------------------------- 1 | import tables 2 | 3 | values 4 | 5 | 6 | discard """ 7 | # either this or "expression has no type": 8 | errormsg: "ambiguous identifier: 'values' -- use one of the following:" 9 | """ 10 | -------------------------------------------------------------------------------- /tests/errmsgs/ta.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | line: 12 4 | """ 5 | 6 | import mb, mc 7 | 8 | proc test(testing: mb.typ) = 9 | discard 10 | 11 | var s: mc.typ 12 | test(s) 13 | -------------------------------------------------------------------------------- /tests/errmsgs/tconstinfo.nim: -------------------------------------------------------------------------------- 1 | # https://forum.nim-lang.org/t/9762 2 | 3 | const foo = "abc" 4 | case 'a' 5 | of foo: echo "should error" #[tt.Error 6 | ^ type mismatch: got but expected 'char']# 7 | else: discard 8 | -------------------------------------------------------------------------------- /tests/errmsgs/tnnodeindexkind.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "cannot set child of node kind: nnkStrLit" 3 | line: 7 4 | """ 5 | import macros 6 | macro t(x: untyped): untyped = 7 | x[0] = newEmptyNode() 8 | t("abc") 9 | -------------------------------------------------------------------------------- /tests/iter/titerautoerr1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'string'" 3 | line: 8 4 | """ 5 | 6 | iterator a(): auto {.closure.} = 7 | if true: return "str" 8 | yield 1 9 | -------------------------------------------------------------------------------- /tests/iter/titerautoerr2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got but expected 'int literal(1)'" 3 | line: 8 4 | """ 5 | 6 | iterator b(): auto {.closure.} = 7 | yield 1 8 | if true: return "str" 9 | -------------------------------------------------------------------------------- /tests/iter/tsubscript.nim: -------------------------------------------------------------------------------- 1 | # issue #14860 2 | 3 | type 4 | Dummie = object 5 | 6 | iterator `[]`(d: Dummie, a, b: int): int = discard 7 | 8 | let d = Dummie() 9 | 10 | for s in d[0, 1]: discard # error here 11 | -------------------------------------------------------------------------------- /tests/let/timportc2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'let' symbol requires an initialization" 3 | line: "7" 4 | """ 5 | 6 | # Test that this still works when not annotated with importc 7 | let test: cint 8 | echo test 9 | -------------------------------------------------------------------------------- /tests/lexer/tinvalidintegerliteral3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "0O5 is an invalid int literal; For octal literals use the '0o' prefix." 3 | file: "tinvalidintegerliteral3.nim" 4 | line: 7 5 | """ 6 | 7 | echo 0O5 8 | -------------------------------------------------------------------------------- /tests/misc/t3907.nim: -------------------------------------------------------------------------------- 1 | import std/assertions 2 | 3 | let a = 0 4 | let b = if false: -1 else: a 5 | doAssert b == 0 6 | 7 | let c: range[0..high(int)] = 0 8 | let d = if false: -1 else: c 9 | 10 | doAssert d == 0 11 | -------------------------------------------------------------------------------- /tests/openarray/topena1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type" 3 | file: "topena1.nim" 4 | line: 9 5 | """ 6 | # Tests a special bug 7 | 8 | var 9 | x: ref openArray[string] #ERROR_MSG invalid type 10 | -------------------------------------------------------------------------------- /tests/pragmas/tuserpragmaargs.nim: -------------------------------------------------------------------------------- 1 | var foo {.exportc: "abc".} = 123 2 | {.pragma: importc2, importc.} 3 | var bar {.importc2: "abc".}: int #[tt.Error 4 | ^ user pragma cannot have arguments]# 5 | echo bar 6 | -------------------------------------------------------------------------------- /tests/stdlib/t7686.nim: -------------------------------------------------------------------------------- 1 | import std/strutils 2 | import std/assertions 3 | 4 | type 5 | MyEnum = enum 6 | A, 7 | a 8 | 9 | doAssert parseEnum[MyEnum]("A") == A 10 | doAssert parseEnum[MyEnum]("a") == a 11 | -------------------------------------------------------------------------------- /tests/typerel/ttynilinstantiation.nim: -------------------------------------------------------------------------------- 1 | proc foo[T: proc](x: T) = 2 | # old error here: 3 | let y = x 4 | # invalid type: 'typeof(nil)' for let 5 | 6 | foo(nil) #[tt.Error 7 | ^ type mismatch: got ]# 8 | -------------------------------------------------------------------------------- /tests/types/tillegaltuplerecursiongeneric.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'RefTree'" 3 | """ 4 | 5 | type 6 | RefTree[T] = ref tuple[le, ri: RefTree[T]; data: T] 7 | RefTreeInt = RefTree[int] 8 | -------------------------------------------------------------------------------- /tests/types/tillegaltyperecursion2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'Executor'" 3 | line: 8 4 | """ 5 | # bug reported by PR #5637 6 | type 7 | Executor[N] = Executor[N] 8 | var e: Executor[int] 9 | -------------------------------------------------------------------------------- /nimsuggest/tests/tv3_definition.nim: -------------------------------------------------------------------------------- 1 | 2 | let foo = 30 3 | let bar = foo + fo#[!]#o + foo 4 | 5 | discard """ 6 | $nimsuggest --v3 --tester $file 7 | >def $1 8 | def skLet tv3_definition.foo int $file 2 4 "" 100 9 | """ 10 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tcolumn.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'undeclared'" 3 | line: 9 4 | column: 7 5 | """ 6 | 7 | # test should fail because the line directive is wrong 8 | echo undeclared 9 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tline.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'undeclared'" 3 | line: 10 4 | column: 6 5 | """ 6 | 7 | # test should fail because the line directive is wrong 8 | echo undeclared 9 | -------------------------------------------------------------------------------- /tests/arc/m24764.nim: -------------------------------------------------------------------------------- 1 | type QObject* {.inheritable.} = object 2 | proc `=destroy`(self: var QObject) = discard 3 | proc `=sink`(dest: var QObject, source: QObject) = discard 4 | proc `=copy`(dest: var QObject, source: QObject) {.error.} -------------------------------------------------------------------------------- /tests/array/tgenericindex.nim: -------------------------------------------------------------------------------- 1 | block: # issue #13184 2 | type 3 | TypeClass = uint | enum | int 4 | ArrayAlias[I: TypeClass] = array[I, int] 5 | 6 | proc test[I: TypeClass](points: ArrayAlias[I]) = 7 | discard 8 | -------------------------------------------------------------------------------- /tests/constructors/t5965_2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "incorrect object construction syntax" 3 | file: "t5965_2.nim" 4 | line: 10 5 | """ 6 | 7 | type Foo = object 8 | a: int 9 | 10 | discard Foo(a: 1, 2) 11 | -------------------------------------------------------------------------------- /tests/enum/tenumfieldpragmanoannot.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "annotation to deprecated not supported here" 3 | line: 8 4 | """ 5 | 6 | type 7 | A = enum 8 | a {.deprecated: "njshd".} 9 | 10 | var v1 = a 11 | -------------------------------------------------------------------------------- /tests/errmsgs/tcant_overload_by_return_type.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "overloaded 'x' leads to ambiguous calls" 3 | line: 9 4 | """ 5 | 6 | # bug #6393 7 | 8 | proc x(): int = 7 9 | proc x(): string = "strange" 10 | -------------------------------------------------------------------------------- /tests/errmsgs/tmultiple_finally.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Only one finally is allowed after all other branches" 3 | """ 4 | 5 | try: 6 | discard 7 | finally: 8 | discard 9 | finally: 10 | discard 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/generics/t1500.nim: -------------------------------------------------------------------------------- 1 | #issue 1500 2 | 3 | type 4 | TFtpBase*[SockType] = object 5 | job: TFTPJob[SockType] 6 | PFtpBase*[SockType] = ref TFtpBase[SockType] 7 | TFtpClient* = TFtpBase[string] 8 | TFTPJob[T] = object -------------------------------------------------------------------------------- /tests/global/tglobalforvar.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: 100 3 | """ 4 | 5 | var funcs: seq[proc (): int {.nimcall.}] = @[] 6 | for i in 0..10: 7 | funcs.add((proc (): int = return i * i)) 8 | 9 | echo(funcs[3]()) 10 | -------------------------------------------------------------------------------- /tests/lexer/tmissingnl.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid indentation" 3 | file: "tmissingnl.nim" 4 | line: 7 5 | """ 6 | 7 | import strutils let s: seq[int] = @[0, 1, 2, 3, 4, 5, 6] 8 | 9 | #s[1..3] = @[] 10 | -------------------------------------------------------------------------------- /tests/manyloc/named_argument_bug/tri_engine/math/circle.nim: -------------------------------------------------------------------------------- 1 | import 2 | ../config, 3 | vec 4 | 5 | type 6 | TCircle* = tuple[p: TV2[TR], r: TR] 7 | 8 | converter toCircle*(o: TR): TCircle = 9 | (newV2(), o) 10 | -------------------------------------------------------------------------------- /tests/manyloc/named_argument_bug/tri_engine/math/rect.nim: -------------------------------------------------------------------------------- 1 | import 2 | tri_engine/config, 3 | tri_engine/math/vec 4 | 5 | type 6 | TRect* = tuple[min, size: TV2[TR]] 7 | 8 | proc max*(o: TRect): TV2[TR] = o.min + o.size 9 | -------------------------------------------------------------------------------- /tests/pragmas/t13306.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'testEpo' can have side effects" 3 | line: 8 4 | """ 5 | 6 | import times 7 | 8 | func testEpo(x: float): float = epochTime() + x 9 | 10 | echo testEpo(1.0) 11 | -------------------------------------------------------------------------------- /tests/stdlib/tfenv.nim: -------------------------------------------------------------------------------- 1 | import std/fenv 2 | import std/assertions 3 | 4 | 5 | func is_significant(x: float): bool = 6 | x > minimumPositiveValue(float) and x < maximumPositiveValue(float) 7 | 8 | doAssert is_significant(10.0) 9 | -------------------------------------------------------------------------------- /tests/stdlib/tmemlines.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "" 3 | """ 4 | 5 | import memfiles 6 | var inp = memfiles.open("tests/stdlib/tmemlines.nim") 7 | for line in lines(inp): 8 | echo("#" & line & "#") 9 | close(inp) 10 | -------------------------------------------------------------------------------- /tests/system/tcopyprotected_arrayinit.nim: -------------------------------------------------------------------------------- 1 | type 2 | Bar = object 3 | b: int = 1 4 | 5 | Foo = object 6 | f: array[1, Bar] 7 | 8 | proc `=copy`(dest: var Bar, source: Bar) {.error.} 9 | 10 | discard Foo() 11 | -------------------------------------------------------------------------------- /tests/template/mdotcall2.nim: -------------------------------------------------------------------------------- 1 | # imported by mdotcall 2 | 3 | proc baseAddr*[T](x: openarray[T]): pointer = 4 | cast[pointer](x) 5 | 6 | proc shift*(p: pointer, delta: int): pointer = 7 | cast[pointer](cast[int](p) + delta) 8 | -------------------------------------------------------------------------------- /tests/template/t21231.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'x'" 3 | """ 4 | 5 | var x: int 6 | # bug #21231 7 | template f(y: untyped) = echo y.x 8 | for i in 1 .. 10: 9 | x = i 10 | f(system) 11 | -------------------------------------------------------------------------------- /tests/template/tparamscope.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "undeclared identifier: 'a'" 3 | line: 10 4 | """ 5 | 6 | 7 | template secondArg(a, b: typed): untyped = 8 | b 9 | 10 | echo secondArg((var a = 1; 1), a) 11 | -------------------------------------------------------------------------------- /tests/vm/toverflowopcaddimmint.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "over- or underflow" 3 | """ 4 | 5 | static: 6 | proc p = 7 | var 8 | x = int64.high 9 | discard x + 1 10 | doAssert false 11 | p() 12 | -------------------------------------------------------------------------------- /tests/vm/toverflowopcmulint.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "over- or underflow" 3 | """ 4 | 5 | static: 6 | proc p = 7 | var 8 | x = 1'i64 shl 62 9 | discard x * 2 10 | doAssert false 11 | p() 12 | -------------------------------------------------------------------------------- /tests/vm/tvarsection.nim: -------------------------------------------------------------------------------- 1 | var 2 | a {.compileTime.} = 2 3 | b = -1 4 | c {.compileTime.} = 3 5 | d = "abc" 6 | 7 | static: 8 | doAssert a == 2 9 | doAssert c == 3 10 | 11 | doAssert ($b & $d) == "-1abc" 12 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/tsortoutput.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | sortoutput: true 3 | output: ''' 4 | 2 5 | 1 6 | ''' 7 | """ 8 | 9 | # this test should ensure that the output is actually sorted 10 | echo "2" 11 | echo "1" 12 | -------------------------------------------------------------------------------- /tests/array/tidx_lit_err1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "size of array exceeds range of index type 'range 1..2(Color)' by 3 elements" 3 | line: 6 4 | """ 5 | type Color = enum Red, Green, Blue 6 | let y = [Green: 0, 1, 2, 3, 4] 7 | -------------------------------------------------------------------------------- /tests/async/ttemplateinasync.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: 42 3 | """ 4 | 5 | import asyncdispatch 6 | 7 | proc foo(): Future[int] {.async.} = 8 | template ret() = return 42 9 | ret() 10 | 11 | echo (waitFor foo()) 12 | -------------------------------------------------------------------------------- /tests/benchmarks/readme.md: -------------------------------------------------------------------------------- 1 | # Collection of benchmarks 2 | 3 | In future work, benchmarks can be added to CI, but for now we provide benchmarks that can be run locally. 4 | 5 | See RFC: https://github.com/timotheecour/Nim/issues/425 6 | -------------------------------------------------------------------------------- /tests/constructors/t5965_1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "incorrect object construction syntax" 3 | file: "t5965_1.nim" 4 | line: 10 5 | """ 6 | 7 | type Foo = object 8 | a, b, c: int 9 | 10 | discard Foo(a: 1, 2) 11 | -------------------------------------------------------------------------------- /tests/cpp/tgen_prototype_for_importc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | output: '''Hello world''' 4 | """ 5 | 6 | # bug #5136 7 | 8 | {.compile: "foo.c".} 9 | proc myFunc(): cstring {.importc.} 10 | echo myFunc() 11 | -------------------------------------------------------------------------------- /tests/errmsgs/t6281.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'SomeNumber' in this context: 'seq[SomeNumber]' for var" 3 | line: 6 4 | """ 5 | 6 | var seqwat: seq[SomeNumber] = @[] 7 | 8 | proc foo(x: SomeNumber) = 9 | seqwat.add(x) -------------------------------------------------------------------------------- /tests/errmsgs/t9908_01.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "ordinal type expected; given: string" 3 | line: 10 4 | """ 5 | 6 | # https://github.com/nim-lang/Nim/issues/9908 7 | 8 | type 9 | X = enum 10 | a = ("a", "b") 11 | -------------------------------------------------------------------------------- /tests/errmsgs/tgeneral_excepts.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "Only one general except clause is allowed after more specific exceptions" 3 | """ 4 | 5 | try: 6 | discard 7 | except: 8 | discard 9 | except: 10 | discard 11 | -------------------------------------------------------------------------------- /tests/errmsgs/tnested_empty_seq.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "invalid type: 'empty' in this context: 'array[0..0, (string, seq[empty])]' for var" 3 | line: 8 4 | """ 5 | 6 | # bug #3948 7 | 8 | var headers=[("headers", @[])] 9 | -------------------------------------------------------------------------------- /tests/exception/twrongexc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "Error: unhandled exception: [ValueError]" 3 | exitcode: "1" 4 | """ 5 | try: 6 | raise newException(ValueError, "") 7 | except OverflowDefect: 8 | echo("Error caught") 9 | -------------------------------------------------------------------------------- /tests/generics/m3770.nim: -------------------------------------------------------------------------------- 1 | type 2 | Noice* = object 3 | hidden: int 4 | 5 | template jjj*: Noice = 6 | Noice(hidden: 15) 7 | 8 | type Opt* = object 9 | o: int 10 | 11 | template none*(O: type Opt): Opt = Opt(o: 0) 12 | -------------------------------------------------------------------------------- /tests/js/tcodegendeclvar.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | -1 4 | 2 5 | ''' 6 | ccodecheck: "'console.log(-1); var v_' \\d+ ' = [2]'" 7 | """ 8 | 9 | var v {.codegenDecl: "console.log(-1); var $2".} = 2 10 | echo v 11 | -------------------------------------------------------------------------------- /tests/lookups/mambsym1.nim: -------------------------------------------------------------------------------- 1 | import mambsym2 # import TExport 2 | 3 | type 4 | TExport* = enum x, y, z 5 | TOtherEnum* = enum mDec, mInc, mAssign 6 | 7 | proc ha() = 8 | var 9 | x: TExport # no error 10 | discard 11 | -------------------------------------------------------------------------------- /tests/modules/mmodule_same_proc.nim: -------------------------------------------------------------------------------- 1 | 2 | # the module being the same name as the proc 3 | # is a requirement to trigger the error 4 | import mmodule_same_proc_client 5 | 6 | proc bar*[T](foo: T): bool = foo.mmodule_same_proc_client() 7 | -------------------------------------------------------------------------------- /tests/modules/trecinca.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "recursive dependency: 'trecincb.nim'" 3 | file: "trecincb.nim" 4 | line: 9 5 | """ 6 | # Test recursive includes 7 | 8 | include trecincb 9 | 10 | echo "trecina" 11 | -------------------------------------------------------------------------------- /tests/newconfig/mconfigcheck.nims: -------------------------------------------------------------------------------- 1 | mode = ScriptMode.Verbose 2 | proc build() = 3 | echo "building nim... " 4 | exec "sleep 10" 5 | exec "nonexistant command" 6 | echo getCurrentDir() 7 | 8 | echo "hello" 9 | build() 10 | -------------------------------------------------------------------------------- /tests/overflow/toverflow2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | outputsub: "Error: unhandled exception: over- or underflow [OverflowDefect]" 3 | exitcode: "1" 4 | """ 5 | var a : int32 = 2147483647 6 | var b : int32 = 2147483647 7 | var c = a + b 8 | -------------------------------------------------------------------------------- /tests/parser/ttypecommandindent3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "expression expected, but found 'keyword do'" 3 | line: 10 4 | column: 1 5 | """ 6 | 7 | type 8 | Foo = call x, y, z: 9 | abc 10 | do: 11 | def 12 | -------------------------------------------------------------------------------- /tests/pragmas/tpragmablock.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--warningaserror:BareExcept" 3 | """ 4 | 5 | {.warning[BareExcept]:on.}: 6 | discard 7 | 8 | try: 9 | echo "Y" 10 | except: # warning disabled here 11 | discard -------------------------------------------------------------------------------- /tests/showoff/thtml1.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "
" 3 | """ 4 | 5 | template htmlTag(tag: untyped) = 6 | proc tag(): string = "<" & astToStr(tag) & ">" 7 | 8 | htmlTag(br) 9 | htmlTag(html) 10 | 11 | echo br() 12 | -------------------------------------------------------------------------------- /testament/tests/shouldfail/treject.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: "reject" 3 | """ 4 | 5 | # Because we set action="reject", we expect this line not to compile. But the 6 | # line does compile, therefore the test fails. 7 | assert true 8 | -------------------------------------------------------------------------------- /tests/arc/t16033.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c js" 3 | matrix: "--gc:arc" 4 | """ 5 | 6 | # bug #16033 7 | when defined js: 8 | doAssert not compileOption("gc", "arc") 9 | else: 10 | doAssert compileOption("gc", "arc") 11 | -------------------------------------------------------------------------------- /tests/ccgbugs/tborrowmagic.nim: -------------------------------------------------------------------------------- 1 | type 2 | Bytes = distinct seq[byte] 3 | 4 | proc add(x: var Bytes; b: byte) {.borrow.} 5 | var x = @[].Bytes 6 | x.add(42) 7 | let base = cast[seq[byte]](x) 8 | doAssert base.len == 1 and base[0] == 42 9 | -------------------------------------------------------------------------------- /tests/ccgbugs/tweakopenarray.nim: -------------------------------------------------------------------------------- 1 | # bug #4089 2 | 3 | type 4 | Proc = proc(args: openArray[Bar]): Bar 5 | 6 | Foo = object 7 | p: Proc 8 | 9 | Bar = object 10 | f: Foo 11 | 12 | proc bar(val: Foo): Bar = Bar() 13 | -------------------------------------------------------------------------------- /tests/generics/t7446.nim: -------------------------------------------------------------------------------- 1 | proc foo(x: Natural or SomeUnsignedInt):int = 2 | when x is int: 3 | result = 1 4 | else: 5 | result = 2 6 | let a = 10 7 | doAssert foo(a) == 1 8 | 9 | let b = 10'u8 10 | doAssert foo(b) == 2 -------------------------------------------------------------------------------- /tests/generics/twrongdotcallcrash.nim: -------------------------------------------------------------------------------- 1 | # issue #25000 2 | 3 | proc r(T: typedesc[int]): int = discard 4 | proc c[J: typedesc[uint]](u = J.r) = discard #[tt.Error 5 | ^ undeclared field: 'r']# 6 | c[uint]() 7 | -------------------------------------------------------------------------------- /tests/misc/t20253.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'result' requires explicit initialization" 3 | line: 10 4 | """ 5 | 6 | type Meow {.requiresInit.} = object 7 | init: bool 8 | 9 | proc initMeow(): Meow = 10 | discard 11 | -------------------------------------------------------------------------------- /tests/misc/åäö.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: run 3 | """ 4 | 5 | # Tests that module names can contain multi byte characters 6 | 7 | let a = 1 8 | doAssert åäö.a == 1 9 | 10 | proc inlined() {.inline.} = discard 11 | inlined() -------------------------------------------------------------------------------- /tests/modules/trecincb.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "recursive dependency: 'trecincb.nim'" 3 | file: "trecincb.nim" 4 | line: 9 5 | """ 6 | # Test recursive includes 7 | 8 | 9 | include trecincb 10 | 11 | echo "trecinb" 12 | -------------------------------------------------------------------------------- /tests/overload/tissue966.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch: got " 3 | """ 4 | 5 | type 6 | PTest = ref object 7 | 8 | proc test(x: PTest, y: int) = discard 9 | 10 | var buf: PTest 11 | buf.test() 12 | 13 | -------------------------------------------------------------------------------- /tests/parallel/t9691.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:refc; --mm:orc" 3 | errormsg: "'spawn'ed function cannot have a 'typed' or 'untyped' parameter" 4 | """ 5 | 6 | # bug #9691 7 | 8 | import threadpool 9 | spawn echo() 10 | -------------------------------------------------------------------------------- /tests/parallel/tsysspawnbadarg.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "'spawn' takes a call expression" 3 | line: 9 4 | cmd: "nim $target --threads:on $options $file" 5 | """ 6 | 7 | import threadpool 8 | 9 | let foo = spawn(1) 10 | -------------------------------------------------------------------------------- /tests/pragmas/tcompile_pragma.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''34''' 3 | joinable: false 4 | """ 5 | 6 | {.compile("cfunction.c", "-DNUMBER_HERE=34").} 7 | 8 | proc cfunction(): cint {.importc.} 9 | 10 | echo cfunction() 11 | -------------------------------------------------------------------------------- /tests/sandwich/mstatic.nim: -------------------------------------------------------------------------------- 1 | type Foo* = object 2 | x*, y*: int 3 | 4 | proc `$`*(x: static Foo): string = 5 | "static Foo(" & $x.x & ", " & $x.y & ")" 6 | 7 | proc `$`*(x: Foo): string = 8 | "runtime Foo(" & $x.x & ", " & $x.y & ")" 9 | -------------------------------------------------------------------------------- /tests/stdlib/mjsonexternproc.nim: -------------------------------------------------------------------------------- 1 | # Test case for https://github.com/nim-lang/Nim/issues/6385 2 | 3 | import json 4 | # export json 5 | 6 | proc foo*[T](a: T) = 7 | let params = %*{ 8 | "data": [ 1 ] 9 | } 10 | echo $params -------------------------------------------------------------------------------- /tests/stdlib/nre/escape.nim: -------------------------------------------------------------------------------- 1 | import nre, unittest 2 | 3 | block: # escape strings 4 | block: # escape strings 5 | check("123".escapeRe() == "123") 6 | check("[]".escapeRe() == r"\[\]") 7 | check("()".escapeRe() == r"\(\)") 8 | -------------------------------------------------------------------------------- /tests/stdlib/tjsonexternproc.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | {"data":[1]} 4 | ''' 5 | """ 6 | 7 | # Test case for https://github.com/nim-lang/Nim/issues/6385 8 | 9 | import mjsonexternproc 10 | # import json 11 | foo(1) 12 | -------------------------------------------------------------------------------- /tests/stdlib/tstrformatlineinfo.nim: -------------------------------------------------------------------------------- 1 | # issue #21759 2 | 3 | {.hint[ConvFromXToItselfNotNeeded]: on.} 4 | 5 | import std/strformat 6 | 7 | echo fmt"{string ""abc""}" #[tt.Hint 8 | ^ conversion from string to itself is pointless]# 9 | -------------------------------------------------------------------------------- /tests/template/template_pragmas.nim: -------------------------------------------------------------------------------- 1 | proc output_x:string {.compileTime.} = "x" 2 | 3 | template t = 4 | const x = output_x() 5 | let 6 | bar {.exportc:"bar" & x.} = 100 7 | 8 | static: 9 | doAssert(compiles (t())) 10 | -------------------------------------------------------------------------------- /tests/template/tqualifiedident.nim: -------------------------------------------------------------------------------- 1 | block: # issue #19865 2 | template f() = discard default(system.int) 3 | f() 4 | 5 | # issue #21221, same as above 6 | type M = object 7 | template r() = discard default(tqualifiedident.M) 8 | r() 9 | -------------------------------------------------------------------------------- /tests/types/tillegaltyperecursion3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'Weird'" 3 | """ 4 | 5 | # issue #3456 6 | 7 | import tables 8 | type 9 | Weird = ref seq[Weird] 10 | var t = newTable[int, Weird]() 11 | -------------------------------------------------------------------------------- /tests/varres/tvarres3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "45" 3 | """ 4 | 5 | var 6 | g = 5 7 | 8 | proc p(): var int = 9 | var bla = addr(g) #: array[0..7, int] 10 | result = bla[] 11 | 12 | p() = 45 13 | 14 | echo g 15 | 16 | -------------------------------------------------------------------------------- /nimsuggest/tests/t22448.nim: -------------------------------------------------------------------------------- 1 | proc fn(a: static float) = discard 2 | proc fn(a: int) = discard 3 | 4 | let x = 1 5 | fn(x) 6 | 7 | discard """ 8 | $nimsuggest --tester --v3 $file 9 | >chk $file 10 | chk;;skUnknown;;;;Hint;;* 11 | """ 12 | -------------------------------------------------------------------------------- /tests/arc/t16558.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--gc:arc" 3 | errormsg: "expression cannot be cast to 'int'" 4 | """ 5 | 6 | block: # bug #16558 7 | var value = "hi there" 8 | var keepInt: int 9 | keepInt = cast[int](value) 10 | -------------------------------------------------------------------------------- /tests/ccgbugs/t9098.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "c cpp js" 3 | output: ''' 4 | {'a', 'b'} 5 | ''' 6 | """ 7 | 8 | var x = new(ref set[char]) 9 | var y = new(ref set[char]) 10 | x[] = {'a'} 11 | y[] = {'b'} 12 | echo x[] + y[] 13 | -------------------------------------------------------------------------------- /tests/compiles/t8630.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: ''' 3 | foo 4 | bar 5 | ''' 6 | """ 7 | 8 | proc test(strings: seq[string]) = 9 | for s in strings: 10 | var p3 = addr(s) 11 | echo p3[] 12 | 13 | test(@["foo", "bar"]) 14 | -------------------------------------------------------------------------------- /tests/converter/tconverter.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''fooo fooo''' 3 | """ 4 | 5 | converter intToString[T](i: T): string = "fooo" 6 | 7 | let 8 | foo: string = 1 9 | bar: string = intToString(2) 10 | 11 | echo foo, " ", bar -------------------------------------------------------------------------------- /tests/cpp/tenum_set.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | targets: "cpp" 3 | output: "{A, B, C}" 4 | """ 5 | 6 | type Enum {.importcpp: "namespaced::Enum", header: "enum.hpp".} = enum A, B, C 7 | 8 | var vals = {low(Enum) .. high(Enum)} 9 | echo vals 10 | -------------------------------------------------------------------------------- /tests/destructor/tgotoexceptions3.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --gc:arc --exceptions:goto $file" 3 | outputsub: "Error: unhandled exception: Problem [OSError]" 4 | exitcode: "1" 5 | """ 6 | 7 | raise newException(OSError, "Problem") 8 | -------------------------------------------------------------------------------- /tests/effects/teffects10.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | action: compile 3 | """ 4 | 5 | # https://github.com/nim-lang/Nim/issues/15495 6 | 7 | proc f() {.raises: [].} = 8 | var a: proc () 9 | var b: proc () 10 | swap(a, b) 11 | 12 | f() 13 | -------------------------------------------------------------------------------- /tests/effects/tlaxeffects.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim $target $options --legacy:laxEffects $file" 3 | """ 4 | 5 | 6 | type 7 | Foo = object 8 | bar: seq[Foo] 9 | 10 | proc `==`(a, b: Foo): bool = 11 | a.bar == b.bar 12 | -------------------------------------------------------------------------------- /tests/errmsgs/t22852.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | exitcode: 1 3 | outputsub: ''' 4 | Error: unhandled exception: value out of range: -2 notin 0 .. 9223372036854775807 [RangeDefect] 5 | ''' 6 | """ 7 | 8 | # bug #22852 9 | echo [0][2..^2] 10 | -------------------------------------------------------------------------------- /tests/errmsgs/t23355.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "{.pop.} without a corresponding {.push.}" 3 | """ 4 | 5 | block: 6 | {.push raises: [].} 7 | 8 | proc f() = 9 | {.pop.} 10 | 11 | proc g() = raise newException(ValueError, "") -------------------------------------------------------------------------------- /tests/errmsgs/trecursiveproctype4.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "illegal recursion in type 'EventHandler'" 3 | line: 9 4 | """ 5 | 6 | # issue #23885 7 | 8 | type 9 | EventHandler = proc(target: BB) 10 | BB = (EventHandler,) 11 | -------------------------------------------------------------------------------- /tests/generics/tfriends.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: "3" 3 | """ 4 | 5 | # Tests that a generic instantiation from a different module may access 6 | # private object fields: 7 | 8 | import mfriends 9 | 10 | echo gen[int]() 11 | 12 | -------------------------------------------------------------------------------- /tests/ic/mimports.nim: -------------------------------------------------------------------------------- 1 | from mimportsb {.all.} import fnb1, hfnb3 2 | 3 | proc fn1*(): int = 1 4 | proc fn2*(): int = 2 5 | proc hfn3(): int = 3 6 | proc hfn4(): int = 4 7 | proc hfn5(): int = 5 8 | 9 | export mimportsb.fnb2, hfnb3 10 | -------------------------------------------------------------------------------- /tests/importalls/mt0.nim: -------------------------------------------------------------------------------- 1 | import ./m1 as m 2 | doAssert compiles(foo0) 3 | doAssert not compiles(foo1) 4 | doAssert foo6b() == 2 5 | doAssert m3h2 == 2 6 | 7 | var f = initFoo5(z3=3) 8 | doAssert f.z3 == 30 9 | doAssert z3(f) == 30 10 | -------------------------------------------------------------------------------- /tests/js/testmagic.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | output: '''true 3 | 123 4 | ''' 5 | """ 6 | 7 | # This file tests some magic 8 | 9 | var foo = cstring("foo") 10 | var bar = cstring("foo") 11 | echo(foo == bar) 12 | echo "01234"[1 .. ^2] 13 | -------------------------------------------------------------------------------- /tests/macros/t21593.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: ''' 3 | StmtList 4 | UIntLit 18446744073709551615 5 | IntLit -1''' 6 | """ 7 | 8 | import macros 9 | 10 | dumpTree: 11 | 0xFFFFFFFF_FFFFFFFF'u 12 | 0xFFFFFFFF_FFFFFFFF 13 | 14 | -------------------------------------------------------------------------------- /tests/macros/treturnsempty.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "type mismatch" 3 | line: 11 4 | """ 5 | # bug #2372 6 | macro foo(dummy: int): untyped = 7 | discard 8 | 9 | proc takeStr(s: string) = echo s 10 | 11 | takeStr foo(12) 12 | -------------------------------------------------------------------------------- /tests/objects/tunsafenew.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "conversion from int literal(-1) to Natural is invalid" 3 | """ 4 | 5 | type 6 | Obj = object 7 | case b: bool 8 | else: discard 9 | var o: ref Obj 10 | unsafeNew(o, -1) -------------------------------------------------------------------------------- /tests/overload/texplicitgenericdiscard.nim: -------------------------------------------------------------------------------- 1 | # issue #8064 2 | 3 | import tables 4 | 5 | values[int] #[tt.Error 6 | ^ ambiguous identifier: 'values' -- use one of the following:]# 7 | # this happens before discard check, so no discard error 8 | -------------------------------------------------------------------------------- /tests/system/t20938.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | cmd: "nim c --mm:refc $file" 3 | action: "compile" 4 | """ 5 | 6 | template foo(x: typed) = 7 | discard x 8 | 9 | foo: 10 | var x = "hello" 11 | x.shallowCopy("test") 12 | true 13 | -------------------------------------------------------------------------------- /tests/tuples/twrongtupleaccess.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "attempting to call undeclared routine: \'setBLAH\'" 3 | file: "twrongtupleaccess.nim" 4 | line: 9 5 | """ 6 | # Bugfix 7 | 8 | var v = (5.0, 10.0) 9 | v.setBLAH(10) 10 | -------------------------------------------------------------------------------- /tests/typerel/ttypedesc_as_genericparam2.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | matrix: "--mm:refc" 3 | errormsg: "'repr' doesn't support 'void' type" 4 | line: 10 5 | """ 6 | 7 | # bug #2879 8 | 9 | var s: seq[int] 10 | echo repr(s.new_seq(3)) 11 | -------------------------------------------------------------------------------- /tests/vm/toverflowopcaddint.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "over- or underflow" 3 | """ 4 | 5 | static: 6 | proc p = 7 | var 8 | x = int64.high 9 | y = 1 10 | discard x + y 11 | doAssert false 12 | p() 13 | -------------------------------------------------------------------------------- /tests/vm/toverflowopcsubint.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "over- or underflow" 3 | """ 4 | 5 | static: 6 | proc p = 7 | var 8 | x = int64.low 9 | y = 1 10 | discard x - y 11 | doAssert false 12 | p() 13 | -------------------------------------------------------------------------------- /nimsuggest/tests/fixtures/minclude_include.nim: -------------------------------------------------------------------------------- 1 | # this file is included and relies on imports within the include 2 | 3 | proc create*(greeting: string = "Hello", subject: string = "World"): Greet = 4 | Greet(greeting: greeting, subject: subject) 5 | -------------------------------------------------------------------------------- /tests/async/tasync_nofuture.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "await expects Future[T], got int" 3 | cmd: "nim c $file" 4 | file: "asyncmacro.nim" 5 | """ 6 | import async 7 | 8 | proc a {.async.} = 9 | await 0 10 | 11 | waitFor a() 12 | -------------------------------------------------------------------------------- /tests/errmsgs/t9908_02.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | errormsg: "ordinal type expected; given: float" 3 | line: 10 4 | """ 5 | 6 | # https://github.com/nim-lang/Nim/pull/9909#issuecomment-445519287 7 | 8 | type 9 | E = enum 10 | myVal = 80.9 11 | -------------------------------------------------------------------------------- /tests/errmsgs/tnoop.nim: -------------------------------------------------------------------------------- 1 | discard """ 2 | nimout: ''' 3 | found 'a' [var declared in tnoop.nim(10, 3)] 4 | ''' 5 | file: "tnoop.nim" 6 | errormsg: "attempting to call routine: 'a'" 7 | """ 8 | 9 | var 10 | a: int 11 | 12 | a() 13 | --------------------------------------------------------------------------------