Generator grabs slice type from proper place

This commit is contained in:
Sasha Koshka 2023-11-29 20:31:07 -05:00
parent 6ddb32fd5c
commit 7cf4067167
2 changed files with 9 additions and 5 deletions

View File

@ -6,10 +6,14 @@ func TestFunction (test *testing.T) {
testString (test,
`
`,
`
[puts string:*Byte]:I32
[main] = loop [puts 'home sweet']
`[puts string:*Byte]:I32
[read fd:Int buf:*Byte count:Index]:Index
[main argc:I32 argv:**Byte] = {
buffer:8:Byte
[read 1 [@[.buffer 0]] 7]
[. buffer 7] = 0
[puts [@[.buffer 0]]]
}
`)
}
// [write 1 (* 72 101 108 108 111 114 108 100 0) 7]

View File

@ -106,7 +106,7 @@ func (this *generator) generateSubscriptLoc (subscript *entity.Subscript) (llvm.
var elementType entity.Type
var dataAddress llvm.Value
sourceType := analyzer.ReduceToBase(subscript.Type())
sourceType := analyzer.ReduceToBase(subscript.Slice.Type())
switch sourceType := sourceType.(type) {
case *entity.TypeSlice:
irSourceType, err := this.generateType(sourceType)