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

DateTime field on Exception produces inconsistent C/++ handling #11081

Closed
disruptek opened this issue Apr 22, 2019 · 5 comments
Closed

DateTime field on Exception produces inconsistent C/++ handling #11081

disruptek opened this issue Apr 22, 2019 · 5 comments

Comments

@disruptek
Copy link
Contributor

Admittedly, I'm a novice and may be missing something, but I'm finding this hard to reason about...

import times

type
        MyError = object of Exception
                clock: DateTime

try:
        var foo = newException(MyError, "")
        #foo.clock = now()
        raise foo
except MyError:
        echo "error"
except Exception:
        echo "exception"
except:
        echo "default"

When compiled with nim c, it yields error.
When compiled with nim cpp, it segfaults.
When compiled with nim cpp --noCppExceptions, it yields default.

Assigning the value to clock has no impact, but change clock from a DateTime to, say, a string, and all is well in the world -- all three compilations yield error when run.

This is devel on Linux.

@disruptek
Copy link
Contributor Author

Problem remains as of

Nim Compiler Version 0.20.99 [Linux: amd64]
Compiled at 2019-07-03
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 0718d6c2cddac89256e2fcde17407f1685f1a457
active boot switches: -d:release

@disruptek
Copy link
Contributor Author

Problem remains as of

Nim Compiler Version 0.20.99 [Linux: amd64]
Compiled at 2019-09-12
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: eb241f424134ff2174dc9b9e2a9e76ef9def7027
active boot switches: -d:danger

@Araq Araq added the Severe label Oct 17, 2019
@awr1
Copy link
Contributor

awr1 commented Oct 17, 2019

Issue is related to inheritance.

type Foo* = object of RootObj

type
  MyError = object of Exception
    xyz: Foo

try:
  var foo = newException(MyError, "")
  raise foo
except MyError:
  echo "error"
except Exception:
  echo "exception"
except:
  echo "default"

gives the same result.

@Araq
Copy link
Member

Araq commented Mar 4, 2020

Will be fixed by #13065

@disruptek
Copy link
Contributor Author

Another bug squashed! Thanks!

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

No branches or pull requests

4 participants