Skip to content

Commit f6f32c3

Browse files
committed
patch 7.4.1546
Problem: Sticky type checking is more annoying than useful. Solution: Remove the error for changing a variable type.
1 parent b4ebf9a commit f6f32c3

5 files changed

Lines changed: 26 additions & 29 deletions

File tree

runtime/doc/eval.txt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 7.4. Last change: 2016 Mar 08
1+
*eval.txt* For Vim version 7.4. Last change: 2016 Mar 12
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -113,16 +113,8 @@ to Float, printf() for Float to String and float2nr() for Float to Number.
113113
*E891* *E892* *E893* *E894* *E907* *E911* *E914*
114114
When expecting a Float a Number can also be used, but nothing else.
115115

116-
*E706* *sticky-type-checking*
117-
You will get an error if you try to change the type of a variable. You need
118-
to |:unlet| it first to avoid this error. String and Number are considered
119-
equivalent though, as well are Float and Number. Consider this sequence of
120-
commands: >
121-
:let l = "string"
122-
:let l = 44 " changes type from String to Number
123-
:let l = [1, 2, 3] " error! l is still a Number
124-
:let l = 4.4 " changes type from Number to Float
125-
:let l = "string" " error!
116+
*no-type-checking*
117+
You will not get an error if you try to change the type of a variable.
126118

127119

128120
1.2 Function references ~
@@ -1969,6 +1961,7 @@ islocked( {expr}) Number TRUE if {expr} is locked
19691961
isnan( {expr}) Number TRUE if {expr} is NaN
19701962
items( {dict}) List key-value pairs in {dict}
19711963
job_getchannel( {job}) Channel get the channel handle for {job}
1964+
job_info( {job}) Dict get information about {job}
19721965
job_setoptions( {job}, {options}) none set options for {job}
19731966
job_start( {command} [, {options}]) Job start a job
19741967
job_status( {job}) String get the status of {job}
@@ -4473,10 +4466,18 @@ job_getchannel({job}) *job_getchannel()*
44734466
<
44744467
{only available when compiled with the |+job| feature}
44754468

4469+
job_info({job}) *job_info()*
4470+
Returns a Dictionary with information about {job}:
4471+
"status" what |job_status()| returns
4472+
"channel" what |job_getchannel()| returns
4473+
"exitval" only valid when "status" is "dead"
4474+
"exit-cb" function to be called on exit
4475+
"stoponexit" |job-stoponexit|
4476+
44764477
job_setoptions({job}, {options}) *job_setoptions()*
44774478
Change options for {job}. Supported are:
4478-
"stoponexit" |job-stoponexit|
4479-
"exit-cb" |job-exit-cb|
4479+
"stoponexit" |job-stoponexit|
4480+
"exit-cb" |job-exit-cb|
44804481

44814482
job_start({command} [, {options}]) *job_start()*
44824483
Start a job and return a Job object. Unlike |system()| and

src/eval.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22091,22 +22091,6 @@ set_var(
2209122091
if (var_check_ro(v->di_flags, name, FALSE)
2209222092
|| tv_check_lock(v->di_tv.v_lock, name, FALSE))
2209322093
return;
22094-
if (v->di_tv.v_type != tv->v_type
22095-
&& !((v->di_tv.v_type == VAR_STRING
22096-
|| v->di_tv.v_type == VAR_NUMBER)
22097-
&& (tv->v_type == VAR_STRING
22098-
|| tv->v_type == VAR_NUMBER))
22099-
#ifdef FEAT_FLOAT
22100-
&& !((v->di_tv.v_type == VAR_NUMBER
22101-
|| v->di_tv.v_type == VAR_FLOAT)
22102-
&& (tv->v_type == VAR_NUMBER
22103-
|| tv->v_type == VAR_FLOAT))
22104-
#endif
22105-
)
22106-
{
22107-
EMSG2(_("E706: Variable type mismatch for: %s"), name);
22108-
return;
22109-
}
2211022094

2211122095
/*
2211222096
* Handle setting internal v: variables separately where needed to

src/testdir/test_alot.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
" A series of tests that can run in one Vim invocation.
22
" This makes testing go faster, since Vim doesn't need to restart.
33

4+
source test_assign.vim
45
source test_backspace_opt.vim
56
source test_cursor_func.vim
67
source test_delete.vim

src/testdir/test_assign.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
" Test for assignment
2+
3+
func Test_no_type_checking()
4+
let v = 1
5+
let v = [1,2,3]
6+
let v = {'a': 1, 'b': 2}
7+
let v = 3.4
8+
let v = 'hello'
9+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1546,
746748
/**/
747749
1545,
748750
/**/

0 commit comments

Comments
 (0)