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

Macros and compile time functions marked as uncovered when only used in expansion of defining module #133

Open
florence opened this issue Jan 17, 2017 · 2 comments

Comments

@florence
Copy link
Owner

A not-well-thought-out brain dump on possible ways to fix:

  1. Do some kind of analysis to guess which compile time functions and macros can't escape the current module, and mark them as ignored.

  2. Try to re-expand the source module, but with it pulling macros from the already expanded module. This would probably involved swapping out the language for one in which cover can control expansion to replace references to macros. This probably won't work at all for macro-defining-macros. This might also much with compile time state.

  3. Do the same language-swapping trick to catch macros and compile time functions as they expand and annotate them live. There are probably a ton of issues with this (like getting the correct requires inserted at the correct time, and not leaking scopes).

  4. The idea case: get some kind of hook into the expander to implement 3 in a better way. (i.e. when the expander attempts to compile/interpret a macro or compile time function, have it use current-compile or call cover's annotator or something).

@jackfirth
Copy link

As a temporary workaround, what about a (module/cover body ...) macro that makes a submodule and immediately requires it? So this:

#lang racket
(require rackunit)

(module/cover racket
  (define-syntax (define-one stx)
    (syntax-case stx ()
      [(_ id) #'(begin (define id 1))])))

(define-one id)
(check-equal? id 1)

Would macro expand into this:

#lang racket
(require rackunit)

(module for-coverage racket
  (define-syntax (define-one stx)
    (syntax-case stx ()
      [(_ id) #'(begin (define id 1))]))
  (provide define-one))

(require 'for-coverage)

(define-one id)
(check-equal? id 1)

This would at least automate the drudgery of sticking macros into a different module and requiring them to ensure cover instruments them properly.

@florence
Copy link
Owner Author

florence commented Jun 15, 2017

This won't work unfortunately: the expander runs on a top level module, so cover doesn't get access until all submodules and the top module have been expanded. For coverage to work the macros have to be in a different file.

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

2 participants