mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add an interface for initialization of vars without an explicit initializer (#6934)
When a `var` is not explicitly given an initializer, initialize it in one of two ways: * If its type implements the new interface `Core.Default`, call `Core.Default.Op` to initialize it. * Otherwise, if its type implements `UnformedInit`, leave it in an unformed state. For now, this is always an uninitialized state, but that will change in the future. * If neither of those apply, the `var` declaration is ill-formed. This is a step towards implementing leads decision #6739 and proposals #257 and #5913. Assisted-by: Gemini 3.1 Pro via Antigravity --------- Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
co-authored by
Geoff Romer
parent
fd2d210c63
commit
ce50f181f1
@@ -113,16 +113,16 @@ fn VectorizedWithOptSpeed(a: array(i32, 65536)*) {
|
||||
// CHECK:STDOUT: !21 = !DILocalVariable(arg: 1, scope: !16, type: !19)
|
||||
// CHECK:STDOUT: !22 = !DILocation(line: 18, column: 9, scope: !16)
|
||||
// CHECK:STDOUT: !23 = !DILocation(line: 19, column: 5, scope: !16)
|
||||
// CHECK:STDOUT: !24 = !DILocation(line: 296, column: 3, scope: !25, inlinedAt: !32)
|
||||
// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk.Int.9452f4c51951679b.Core:AddAssignWith.5375cfcbca6d9e35.Core.57ee91777b6354a8", scope: null, file: !26, line: 296, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29)
|
||||
// CHECK:STDOUT: !24 = !DILocation(line: 299, column: 3, scope: !25, inlinedAt: !32)
|
||||
// CHECK:STDOUT: !25 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk.Int.9452f4c51951679b.Core:AddAssignWith.5375cfcbca6d9e35.Core.57ee91777b6354a8", scope: null, file: !26, line: 299, type: !27, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !29)
|
||||
// CHECK:STDOUT: !26 = !DIFile(filename: "{{.*}}/prelude/types/int.carbon", directory: "")
|
||||
// CHECK:STDOUT: !27 = !DISubroutineType(types: !28)
|
||||
// CHECK:STDOUT: !28 = !{null, !7, !7}
|
||||
// CHECK:STDOUT: !29 = !{!30, !31}
|
||||
// CHECK:STDOUT: !30 = !DILocalVariable(arg: 1, scope: !25, type: !7)
|
||||
// CHECK:STDOUT: !31 = !DILocalVariable(arg: 2, scope: !25, type: !7)
|
||||
// CHECK:STDOUT: !32 = distinct !DILocation(line: 362, column: 5, scope: !33, inlinedAt: !38)
|
||||
// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 360, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36)
|
||||
// CHECK:STDOUT: !32 = distinct !DILocation(line: 365, column: 5, scope: !33, inlinedAt: !38)
|
||||
// CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.Int.9452f4c51951679b.Core:Inc.Core.be1e879c1ad406d8", scope: null, file: !26, line: 363, type: !34, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !36)
|
||||
// CHECK:STDOUT: !34 = !DISubroutineType(types: !35)
|
||||
// CHECK:STDOUT: !35 = !{null, !7}
|
||||
// CHECK:STDOUT: !36 = !{!37}
|
||||
|
||||
Reference in New Issue
Block a user