Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nim never terminates and keep write to stderr #19493

Open
ianfun opened this issue Feb 5, 2022 · 0 comments
Open

nim never terminates and keep write to stderr #19493

ianfun opened this issue Feb 5, 2022 · 0 comments

Comments

@ianfun
Copy link
Contributor

ianfun commented Feb 5, 2022

The nim program keeps throwing up errors when I was using sublime-text building source

I was trying concept keyword

In nim playground, process was killed

In sublime-text, process never died (more then 1 minute)

In Terminal, window terminal almost crashed

source

type
  Ordering = enum Lower= -1, Equal=0, Greater=1
  Eq = concept a
    a == a is bool
    a /= a is bool
  Ord = concept o
    compare o o is Ordering
    o < o is bool
    o > o is bool
    o <= o is bool
    o >= o is bool
    max o, o is o
    min o, o is o

when isMainModule:
  type SubClass* = object
    real: float

  func min(x, y: Ord): Ord {.inline.} =
    if x <= y: x else: y

  func max(x, y: Ord): Ord {.inline.} =
    if y <= x: x else: y
  
  func `>=`(x, y: Ord): bool = x > y and x==y
  
  func `<=`(x, y: Ord): bool = x < y and x==y
  
  func `==`(a, b: SubClass): bool = a.real == b.real
  
  func `>`(a, b: SubClass): bool = a.real > b.real
  
  func `<`(a, b: SubClass): bool = a.real < b.real
  
  func compare(a, b: SubClass): Ordering = 
    if a < b:
      Lower
    elif a > b:
      Greater
    else:
      Equal
  let 
    a = SubClass(real: 21)
    b=SubClass(real: 23.1)
  echo a==b
  echo compare(a, b)
  echo max(a, b)  

command line

nim c foo.nim

Current Output

c

c

repeat forever...

version

Nim Compiler Version 1.6.2 [Windows: amd64]
Compiled at 2021-12-17
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release

also test in 1.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant