compiler: convert to ByteArray for string variables
Convert to ByteArray when converting variable to `string`, because underlying byte-slice changes should not affect result string.
This commit is contained in:
parent
1d275ceb65
commit
2c5ab95b8a
2 changed files with 17 additions and 1 deletions
|
@ -86,3 +86,15 @@ func TestTypeConversion(t *testing.T) {
|
|||
|
||||
eval(t, src, big.NewInt(42))
|
||||
}
|
||||
|
||||
func TestTypeConversionString(t *testing.T) {
|
||||
src := `package foo
|
||||
type mystr string
|
||||
func Main() mystr {
|
||||
b := []byte{'l', 'a', 'm', 'a', 'o'}
|
||||
s := mystr(b)
|
||||
b[0] = 'u'
|
||||
return s
|
||||
}`
|
||||
eval(t, src, []byte("lamao"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue