Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@pocke
Copy link

@pocke pocke commented Sep 23, 2017

Problem

If RUBYOPT=-w exists, Ruby warns when we execute :ruby at first time.

Reproduce

Start Vim with RUBYOPT environment

$ RUBYOPT='-w' vim -N -u NONE

Execute :ruby

:ruby puts "hello"

stderr

-e:1: warning: possibly useless use of a literal in void context

The output disturbs the display.

Cause

Vim executes Ruby like ruby -e0. Then the 0 is in void context. So, Ruby warns about it.

Solution

Assign 0 to _. It suppresses the warning. And it does nothing.

Problem
======

If `RUBYOPT=-w` exists, Ruby warns when we execute `:ruby` at first time.

Reproduce
------

Start Vim with `RUBYOPT` environment

```bash
$ RUBYOPT='-w' vim -N -u NONE
```

Execute `:ruby`

```vim
:ruby puts "hello"
```

stderr

```
-e:1: warning: possibly useless use of a literal in void context
```

Cause
====

Vim executes Ruby like `ruby -e0`. Then the `0` is in void context. So, Ruby warns about it.

Solution
======

Assign 0 to `_`. It suppresses the warning. And it does nothing.
@codecov-io
Copy link

Codecov Report

Merging #2143 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2143      +/-   ##
==========================================
+ Coverage   73.94%   73.96%   +0.01%     
==========================================
  Files          90       90              
  Lines      131877   131877              
  Branches    28961    28960       -1     
==========================================
+ Hits        97518    97539      +21     
+ Misses      34336    34315      -21     
  Partials       23       23
Impacted Files Coverage Δ
src/if_ruby.c 56.46% <100%> (ø) ⬆️
src/version.c 76.76% <0%> (-3.54%) ⬇️
src/ex_cmds.c 77.71% <0%> (-0.23%) ⬇️
src/libvterm/src/screen.c 71.37% <0%> (+0.02%) ⬆️
src/gui_gtk_x11.c 47.86% <0%> (+0.15%) ⬆️
src/window.c 81.58% <0%> (+0.55%) ⬆️
src/gui_beval.c 44.47% <0%> (+4.6%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e745d75...9bd77e0. Read the comment docs.

@brammool brammool closed this in d1bc96c Sep 26, 2017
@pocke pocke deleted the supress-ruby-warning branch October 13, 2017 05:24
adizero pushed a commit to adizero/vim that referenced this pull request May 19, 2018
Problem:    Ruby command triggers a warning when RUBYOPT is set to "-w".
Solution:   use "-e_=0" instead of "-e0". (Masataka Pocke Kuwabara, closes
            vim#2143)
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.

2 participants