Bug 176262

Summary: WSL should check unreachable code and no returns
Product: WebKit Reporter: Filip Pizlo <fpizlo>
Component: WebGPUAssignee: Filip Pizlo <fpizlo>
Status: RESOLVED FIXED    
Severity: Normal CC: keith_miller, mmaxfield, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 176199    
Attachments:
Description Flags
the patch mmaxfield: review+

Description Filip Pizlo 2017-09-01 18:19:12 PDT
Patch forthcoming.
Comment 1 Filip Pizlo 2017-09-01 18:23:43 PDT
Created attachment 319684 [details]
the patch
Comment 2 Myles C. Maxfield 2017-09-01 19:18:17 PDT
Comment on attachment 319684 [details]
the patch

I'd like to add control flow statements soon. Hopefully I'm up to the task!
Comment 3 Filip Pizlo 2017-09-01 19:33:02 PDT
(In reply to Myles C. Maxfield from comment #2)
> Comment on attachment 319684 [details]
> the patch
> 
> I'd like to add control flow statements soon. Hopefully I'm up to the task!

The nice thing about those is that the type system basically doesn't have to know about them, so you can probably just let the Checker's and NameResolver's default Visitor methods take care of those control flow nodes.

The one exception is ternaries.  But that's easy - just verify that the two cases return the same type, and then return that type.

I guess to do control flow, we'll either need a bool type, or we'll need a story for which types can be used as bools.  How should that work?

I guess bool could be a native type.  Then you'd need to add a BoolLiteral class.  Shouldn't be that hard.  Do you want to do that, too?
Comment 4 Filip Pizlo 2017-09-01 19:34:27 PDT
Landed in https://trac.webkit.org/changeset/221513/webkit
Comment 5 Myles C. Maxfield 2017-09-02 10:54:38 PDT
(In reply to Filip Pizlo from comment #3)
> (In reply to Myles C. Maxfield from comment #2)
> > Comment on attachment 319684 [details]
> > the patch
> > 
> > I'd like to add control flow statements soon. Hopefully I'm up to the task!
> 
> The nice thing about those is that the type system basically doesn't have to
> know about them, so you can probably just let the Checker's and
> NameResolver's default Visitor methods take care of those control flow nodes.
> 
> The one exception is ternaries.  But that's easy - just verify that the two
> cases return the same type, and then return that type.
> 
> I guess to do control flow, we'll either need a bool type, or we'll need a
> story for which types can be used as bools.  How should that work?
> 
> I guess bool could be a native type.  Then you'd need to add a BoolLiteral
> class.  Shouldn't be that hard.  Do you want to do that, too?

HLSL, GLSL, Metal, and OpenCL all have a native bool type. I see no reason to be different here.
Comment 6 Radar WebKit Bug Importer 2017-09-27 12:54:00 PDT
<rdar://problem/34694242>
Comment 7 Myles C. Maxfield 2018-10-13 17:09:51 PDT
Migrated to https://github.com/gpuweb/WHLSL/issues/161