• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37241
77%

Build:
DEFAULT BRANCH: master
Ran 23 Aug 2022 11:33AM UTC
Jobs 1
Files 381
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
#37241

push

local

web-flow
implement `compilerbarrier` builtin (#46432)

This builtin is useful to control compiler behavior.
It could be considered as a more robust and generalized version of `inferencebarrier`.

I scratched the following docstring for `compilerbarrier`, that hopefully
explains its purpose.

    Base.compilerbarrier(setting::Symbol, val)

This function puts a barrier at a specified compilation phase.
It is supposed to only influence the compilation behavior according to `setting`,
and its runtime semantics is just to return the second argument `val` (except that
this function will perform additional checks on `setting` in a case when `setting`
isn't known precisely at compile-time.)

Currently either of the following `setting`s is allowed:
- Barriers on abstract interpretation:
* `:type`: the return type of this function call will be inferred as `Any` always
(the strongest barrier on abstract interpretation)
* `:const`: the return type of this function call will be inferred with widening
constant information on `val`
* `:conditional`: the return type of this function call will be inferred with widening
conditional information on `val` (see the example below)
- Any barriers on optimization aren't implemented yet

!!! note
    This function is supposed to be used _with `setting` known precisely at compile-time_.
    Note that in a case when the `setting` isn't known precisely at compile-time, the compiler
    currently will put the most strongest barrier(s) rather than emitting a compile-time warning.

\# Examples

```julia
julia> Base.return_types((Int,)) do a
       x = compilerbarrier(:type, a) # `x` won't be inferred as `x::Int`
       return x
   end |> only
Any

julia> Base.return_types() do
       x = compilerbarrier(:const, 42)
       if x == 42 # no constant information here, so inference also accounts for the else branch
           return x # but `x` is still inferred as `x::Int` at least here
       else
    ... (continued)

78913 of 84630 relevant lines covered (93.24%)

33715566.69 hits per line

Jobs
ID Job ID Ran Files Coverage
1 #37241.1 23 Aug 2022 11:33AM UTC 0
93.24
Source Files on build #37241
Detailed source file information is not available for this build.
  • Back to Repo
  • df3da058 on github
  • Prev Build on master
  • Next Build on master
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc