@@ -3847,7 +3847,7 @@ enum compile_array_type_t {
3847
3847
};
3848
3848
3849
3849
static inline int
3850
- static_literal_node_p (const NODE * node )
3850
+ static_literal_node_p (const NODE * node , const rb_iseq_t * iseq )
3851
3851
{
3852
3852
node = node -> nd_head ;
3853
3853
switch (nd_type (node )) {
@@ -3856,13 +3856,19 @@ static_literal_node_p(const NODE *node)
3856
3856
case NODE_TRUE :
3857
3857
case NODE_FALSE :
3858
3858
return TRUE;
3859
+ case NODE_STR :
3860
+ if (ISEQ_COMPILE_DATA (iseq )-> option -> frozen_string_literal ) {
3861
+ return TRUE;
3862
+ } else {
3863
+ return FALSE;
3864
+ }
3859
3865
default :
3860
3866
return FALSE;
3861
3867
}
3862
3868
}
3863
3869
3864
3870
static inline VALUE
3865
- static_literal_value (const NODE * node )
3871
+ static_literal_value (const NODE * node , rb_iseq_t * iseq )
3866
3872
{
3867
3873
node = node -> nd_head ;
3868
3874
switch (nd_type (node )) {
@@ -3872,6 +3878,8 @@ static_literal_value(const NODE *node)
3872
3878
return Qtrue ;
3873
3879
case NODE_FALSE :
3874
3880
return Qfalse ;
3881
+ case NODE_STR :
3882
+ return freeze_literal (iseq , node -> nd_lit );
3875
3883
default :
3876
3884
return node -> nd_lit ;
3877
3885
}
@@ -3921,7 +3929,7 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro
3921
3929
}
3922
3930
break ;
3923
3931
}
3924
- if (opt_p && !static_literal_node_p (node )) {
3932
+ if (opt_p && !static_literal_node_p (node , iseq )) {
3925
3933
opt_p = 0 ;
3926
3934
}
3927
3935
@@ -3943,15 +3951,15 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node_ro
3943
3951
node = start_node ;
3944
3952
3945
3953
while (node != end_node ) {
3946
- rb_ary_push (ary , static_literal_value (node ));
3954
+ rb_ary_push (ary , static_literal_value (node , iseq ));
3947
3955
node = node -> nd_next ;
3948
3956
}
3949
3957
while (node && node -> nd_next &&
3950
- static_literal_node_p (node ) &&
3951
- static_literal_node_p (node -> nd_next )) {
3958
+ static_literal_node_p (node , iseq ) &&
3959
+ static_literal_node_p (node -> nd_next , iseq )) {
3952
3960
VALUE elem [2 ];
3953
- elem [0 ] = static_literal_value (node );
3954
- elem [1 ] = static_literal_value (node -> nd_next );
3961
+ elem [0 ] = static_literal_value (node , iseq );
3962
+ elem [1 ] = static_literal_value (node -> nd_next , iseq );
3955
3963
rb_ary_cat (ary , elem , 2 );
3956
3964
node = node -> nd_next -> nd_next ;
3957
3965
len ++ ;
0 commit comments