diff --git a/src/core/compileInputs.go b/src/core/compileInputs.go index c4d5f1a..724f089 100644 --- a/src/core/compileInputs.go +++ b/src/core/compileInputs.go @@ -23,11 +23,12 @@ func (f *Function) compileInputs() { for _, field := range structType.Fields { param := &ssa.Parameter{ - Index: uint8(offset + i), - Name: fmt.Sprintf("%s.%s", input.Name, field.Name), - Typ: field.Type, - Tokens: input.Tokens, - Source: input.Source, + Index: uint8(offset + i), + Name: fmt.Sprintf("%s.%s", input.Name, field.Name), + Typ: field.Type, + Tokens: input.Tokens, + Structure: structure, + Source: input.Source, } f.Append(param) diff --git a/src/ssa/Parameter.go b/src/ssa/Parameter.go index cac7495..23434c3 100644 --- a/src/ssa/Parameter.go +++ b/src/ssa/Parameter.go @@ -9,9 +9,10 @@ import ( // Parameter is an input parameter for a function call. type Parameter struct { - Typ types.Type - Name string - Tokens token.List + Typ types.Type + Name string + Tokens token.List + Structure *Struct Liveness Source Index uint8 @@ -20,6 +21,7 @@ type Parameter struct { func (v *Parameter) Inputs() []Value { return nil } func (v *Parameter) IsConst() bool { return true } func (v *Parameter) Replace(Value, Value) {} +func (v *Parameter) Struct() *Struct { return v.Structure } func (v *Parameter) String() string { return fmt.Sprintf("args[%d]", v.Index) } func (v *Parameter) Type() types.Type { return v.Typ } diff --git a/tests/ignore-unused-field.q b/tests/ignore-unused-field.q new file mode 100644 index 0000000..85997d6 --- /dev/null +++ b/tests/ignore-unused-field.q @@ -0,0 +1,14 @@ +main() { + foo("foo") + bar("bar") +} + +foo(s string) { + _(s.ptr) +} + +bar(s string) { + _(s.len) +} + +_(_ any) {} \ No newline at end of file diff --git a/tests/tests_test.go b/tests/tests_test.go index 358500d..3bb3a4d 100644 --- a/tests/tests_test.go +++ b/tests/tests_test.go @@ -60,6 +60,7 @@ var tests = []run{ {"return-3", "", "", 0}, {"return-4", "", "", 0}, {"return-string", "", "Hello\n", 0}, + {"ignore-unused-field", "", "", 0}, {"hello", "", "Hello\nHello\nHello\n", 0}, {"escape", "", "a\tb\nc\td\n", 0}, {"script", "", "Hello\n", 0},