Skip to content

Conversation

PhilipWitte
Copy link
Contributor

Very simple first bug fix :) Tested with:

# foo.nim
type Bar* = object
  b*: int

type Baz* = object
  b*: string

proc new*(T:typedesc[Bar], b:int): Bar =
  result.b = b

proc new*(T:typedesc[Baz], b:string): Baz =
  result.b = b
import foo

var br = Bar.new(120)
var bz = Baz.new("hello")

echo br.b
echo bz.b

@PhilipWitte
Copy link
Contributor Author

This bug has been fixed in recent changes to the compiler. Closing PR.

@PhilipWitte PhilipWitte closed this Feb 6, 2014
Clyybber pushed a commit to Clyybber/Nim that referenced this pull request Sep 16, 2023
## Summary

Always include support for logging the VM bytecode generated during
compile-time execution in the compiler. `-d:expandVmListing` is re-used
for selecting what to output. In addition, the feature is decoupled from
the legacy reporting machinery.

The goal is improve the debugging experience when working on the VM, by
not having to temporarily re-build the compiler with
`nimVMDebugGenerate` when wanting to log the the generated bytecode.

## Details

* move rendering of VM code listing from `cli_reporter` to `vmutils`,
  with some minor code-style adjustments applied
* add the `logBytecode` procedure to the `compilerbridge` module. It is
  responsible for deciding what to render, invoking the renderer, and
  writing the result to the output (via `msgWrite`)
* call `logBytecode` whenever new bytecode becomes available
* remove the `rdbgVmCodeListing` report, the data types related to it,
  and the special handling for it in `options`
* change `codeListing` to be a proc, as it doesn't adhere to the
  "strict funcs" requirements
* remove all usages of `nimVMDebugGenerate`
* update the feature's documentation in `debug.rst`

The key difference that allows for always including the logging support
is that a code listing is only created when it's meant to be rendered.
Previously, a listing was created for *all* code (even if it was only
discarded afterwards), which introduced non-negligible overhead.
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

Successfully merging this pull request may close these issues.

1 participant