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

objChecks:off not respected in pragma form #1208

Open
disruptek opened this issue Feb 25, 2024 · 2 comments
Open

objChecks:off not respected in pragma form #1208

disruptek opened this issue Feb 25, 2024 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@disruptek
Copy link
Contributor

Specification

The objChecks boolean flag toggles object conversion checks. It may be disabled via configuration or by using a push pragma.

Example

proc example[A](runtime: Foo[A]) =
  {.push objChecks: off.}
  var temporary: Continuation = fn(runtime.continuation)
  runtime.continuation = A temporary
  {.pop.}

Actual Output

Error: unhandled exception: invalid object conversion [ObjectConversionDefect]

Expected Output

Additional Information

Nimskull Compiler Version 0.1.0-dev.21240 [linux: amd64]

Source hash: 55deaaa31f54f81b4c21db86c93230cb629a7822
Source date: 2024-02-24

active boot switches: -d:release -d:danger⏎ 
@disruptek disruptek added the bug Something isn't working label Feb 25, 2024
@zerbina
Copy link
Collaborator

zerbina commented Feb 25, 2024

As a temporary workaround, you can move .push outside of the procedure, like so:

{.push objChecks: off.}

proc example() =
  ...

{.pop.}

The long-standing problem is that .push and .pop only apply to procedures, which also affects all the other check pragmas (e.g., boundChecks, rangeChecks, etc.). It should also be possible to use objChecks: off directly on the procedure, but that's currently not implemented.


Regarding fixing this, mirgen already supports intra-procedure check enabling/disabling, what's missing is processing the .push and .pop pragmas and implementing the option stack semantics. I'm busy with other things for the next week or so, but I could work on this afterwards.

@zerbina zerbina added this to the MIR phase milestone Feb 25, 2024
@disruptek
Copy link
Contributor Author

Please don't sweat it; plenty of workarounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants