Compiler error: "... is T too nested for type matching"

2021-07-03 Thread stu002
I have a hierarchy of concepts and concept implementations similar to the setup in the Emmy library: After I added one more concept-with-base-concept I started seeing this compiler error: `add(x, y) is T too nested for typ

Cannot properly internationalize

2021-07-03 Thread juancarlospaco
Make a shared lib with only strings, kinda like `translations.nim` \--> `translations.so`. Report bugs to the libs that do not work, lib devs can not read minds yet, so the only way is to report an issue. :)

Cannot properly internationalize

2021-07-03 Thread iortega
Hello, I have lately been trying to internationalize to at least 2 languages a program I am making. For that matter, I have been using [nimterlingua](https://github.com/juancarlospaco/nim-nimterlingua) and [i18n](https://github.com/Parashurama/nim-i18n). However I have problems with both of th

parsecsv crashing witn OverflowDefect error

2021-07-03 Thread Scotpip
@ynfle Great catch! I should have realised there was something suspicious about that figure. The problem isn't my hardware, it's my wetware. I somehow managed to install the 32 bit version of Nim. I was having a wrestle with a false positive from Defender as I tried to download, and it must ha

Nested string format error:

2021-07-03 Thread ynfle
import strutils, strformat, seqUtils var cols = @[1] echo cols.mapIt(&"{it}").join("\n") echo fmt"""Prefix text: {cols.mapIt(&"\{it\:20\}").join("\n")}""" Run works on the devel branch of nim. The primary change is escaping the curly braces (which only works on deve

parsecsv crashing witn OverflowDefect error

2021-07-03 Thread ynfle
L.offsetBase += pos Run it fails on this line in `lexbase.nim` so my guess is that because `L.offsetBase` is an int, and `int32.high div 51_387_744 == 41` which means that the parser is failing because the offset in the file is too many characters to be stored in an `int32` (

parsecsv crashing witn OverflowDefect error

2021-07-03 Thread ynfle
Please post a link to the csv

Nested string format error:

2021-07-03 Thread pedroos
Yes, I just realized I can concat the strings: import strutils, strformat, seqUtils var cols : seq[int] add(cols, 1) #echo &"Prefix text: {join(mapIt(cols, &"{it:20}"), "\n")}" # Error: undeclared identifier: '{}' echo "Prefix text: " & join(mapIt(cols, &"{i

parsecsv crashing witn OverflowDefect error

2021-07-03 Thread Scotpip
I very much appreciate your efforts to help. But it really can't be the specific row in the file that is causing the crash. I've inspected it in Vim, and it's well formed as I said. There are no strange characters, and the length is only 40 chars, so I can't see how it could have anything to do

parsecsv crashing witn OverflowDefect error

2021-07-03 Thread ynfle
Would you mind posting a link to the csv?

Safe `enum` conversion

2021-07-03 Thread ynfle
Just a tip, you can use raise newException(ValueError, "msg goes here") Run

parsecsv crashing witn OverflowDefect error

2021-07-03 Thread Fire
Maybe raise an issue at ? That is generally the place to report this sort of thing. Also, is there a way to obtain this exact data and try to reproduce the result? Kaggle or something?

Nested string format error:

2021-07-03 Thread xigoi
The outer `&` is trying to format the inner braces (and obviously failing). I don't know if escaping them would work, but you really should unnest the expression.

Safe `enum` conversion

2021-07-03 Thread Zoom
I'm a bit puzzled to see this question coming from you of all people. This is a basic pattern of a failable data conversion which calls for the `Result` type. Am I not getting something? What's the catch?

parsecsv crashing witn OverflowDefect error

2021-07-03 Thread Scotpip
I was sceptical that the data would be the issue - I harvested it myself and know the quality. But I did another run and caught the precise line where it occurred. There is nothing wrong with the line - it's well formed and only 40 chars long. I've visually inspected the file and there's nothin

parsecsv crashing witn OverflowDefect error

2021-07-03 Thread enthus1ast
Is the line content or the line number produce the crash? Can you swap this line with another and see if the crash happens one the same line number?

parsecsv crashing witn OverflowDefect error

2021-07-03 Thread cblake
I think the problem must be triggered by something in your data. What I would recommend is changing your main loop to: var count: uint64 = 1 while p.readRow(): inc count stderr.write count, '\n' Run Then compile & run your program again only now you wi

parsecsv crashing witn OverflowDefect error

2021-07-03 Thread Scotpip
Hi Just rolling up my sleeves to learn Nim, but have run into an immediate roadblock. I though I'd stress-test it by reading in a large .csv file, as this will be a common requirement. My code is crashing after reading around 51,000,000 lines. It was only a test so all I'm doing is counting t

Nested string format error:

2021-07-03 Thread pedroos
Hi, so from your tip I would guess I would change the outer string to a triple-quoted string: like echo &"""Prefix text: {join(mapIt(cols, &"{it:20}"), "\n")}""" # Error: closing " expected Run But I get `Error: closing " expected`. I'm out of ideas so if you would

Nested string format error:

2021-07-03 Thread timothee
syntax highlight should've hinted you at your mistake, you need to escape `"` or use `"""`

Nested string format error:

2021-07-03 Thread pedroos
Hi, I'm trying to use a nested string format, with a "big" string outside and a `map` inside with sub-format strings for each element. Why does it not compile? Is there any idiomatic way of using such nested formatted strings? #https://play.nim-lang.org/#ix=3rPJ import strutils,

nim-ws - websockets for Nim

2021-07-03 Thread Araq
> Go decided differently, to make simple cases harder but complex cases easier, > but that path is not for everyone. I know of no studies on that topic. Mechanically adding `if (err) { return err; }` and pretending that it means "you always keep thinking about the error case" is a most naive as

Safe `enum` conversion

2021-07-03 Thread planetis
My submission: import macros, fusion/astdsl macro toEnumImpl(x, res: typed): untyped = template raiseInvalidConv() = raise newException(ValueError, $x & "' can't be converted to " & $typeSym) let typeSym = getTypeInst(res) let typeNode = getT

nim-ws - websockets for Nim

2021-07-03 Thread alexeypetrushin
There's conflict of interests. Errors are exceptional cases in simple or one-timer run programs and could be ignored. Errors are not exceptional cases for long running programs and could not be ignored. There are no way to satisfy both use cases (actually, Erlang did it by assembling program as

Pragma to restrict procedure to main thread?

2021-07-03 Thread Araq
It's declared in the first line of my snippet.

nim-ws - websockets for Nim

2021-07-03 Thread Araq
> you can think about the errors and in some cases you might do extra cleanup > in case of it you would surely have forgotten to write if you didn't set > yourself to write the error handler The price is very high and it depends on your requirements. In the Nim compiler every call can raise an

Safe `enum` conversion

2021-07-03 Thread ElegantBeef
Well it does not even need a macro the above works fine simply modified. import std/options proc toEnum*(val: SomeInteger, E: typedesc[enum]): Option[E] = const enmRange = E.low.ord .. E.high.ord when E is Ordinal: if val in enmRange: some(val)

Safe `enum` conversion

2021-07-03 Thread mildred
Just trolling, but that's why in Go, type casts also return a boolean for you to check, and since it's a tuple result, you have to handle it instead of chaining your value to something else. Couldn't this be implemented in a macro returning an `Option[X]`? type X = enum Z

nim-ws - websockets for Nim

2021-07-03 Thread mildred
Let me reply on the side for > By that definition pretty much all lines are problematic since most of them > can throw. Nim isn't Go and for a good reason, writing error propagation > logic manually is a waste of time. I kind of disagree with that. Sure, in Go you have to write the error logic

Pragma to restrict procedure to main thread?

2021-07-03 Thread mildred
Thank you, I was more expecting a compile time pragma, but that would do. Just a question, I could not find `mainThread` in the library documentation. Where can I find it? Thank you

Safe `enum` conversion

2021-07-03 Thread ElegantBeef
Stealing a macro from the `std/setutils` in devel, got an _ok_ implementation for holey and non-holey enums: import std/macros type X = enum Z type HoleyEnum = enum AVal = 3 BVal = 5 macro enumElementsAsSet(enm: typed): untyp

Safe `enum` conversion

2021-07-03 Thread arnetheduck
A common source of remote exploits in Nim is that of `enum` conversions done like so: type X = enum Z var a = 42 var b = X(a) Run This will fail with a `RangeDefect` which subsequently crashes the application - unfortunately it gets used liberally i

nim-ws - websockets for Nim

2021-07-03 Thread arnetheduck
> By that definition pretty much all lines are problematic since most of them > can throw. Lol, try reading the whole sentence, and you might catch its meaning. > No, the whole point of I hope you'll agree that it's a bit hard to understand what "the whole point" is and when we're asking for t