Bug 176675 - IntLiteral should prefer int32 during overload resolution
Summary: IntLiteral should prefer int32 during overload resolution
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGPU (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords: InRadar
Depends on:
Blocks: 176199
  Show dependency treegraph
 
Reported: 2017-09-10 14:56 PDT by Filip Pizlo
Modified: 2018-10-13 16:52 PDT (History)
5 users (show)

See Also:


Attachments
the patch (7.64 KB, patch)
2017-09-10 16:56 PDT, Filip Pizlo
mmaxfield: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2017-09-10 14:56:13 PDT
This should resolve unambiguously:

int foo(int)
uint foo(uint)
foo(42)

This should be an error:

uint foo(uint)
double foo(double)
foo(42)
Comment 1 Filip Pizlo 2017-09-10 16:56:35 PDT
Created attachment 320407 [details]
the patch
Comment 2 Myles C. Maxfield 2017-09-11 08:39:08 PDT
Comment on attachment 320407 [details]
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=320407&action=review

> Tools/WebGPUShadingLanguageRI/Test.js:1439
> +            int foo<T>(T) { return 1; }

Why should this fail? I would expect T to become an int.
Comment 3 Filip Pizlo 2017-09-11 10:09:21 PDT
(In reply to Myles C. Maxfield from comment #2)
> Comment on attachment 320407 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=320407&action=review
> 
> > Tools/WebGPUShadingLanguageRI/Test.js:1439
> > +            int foo<T>(T) { return 1; }
> 
> Why should this fail? I would expect T to become an int.

I think that's what we should eventually do.  It would take some extra effort to implement this.

Filed: https://bugs.webkit.org/show_bug.cgi?id=176707
Comment 4 Filip Pizlo 2017-09-11 10:21:04 PDT
Landed in https://trac.webkit.org/changeset/221859/webkit
Comment 5 Myles C. Maxfield 2017-09-11 11:25:46 PDT
(In reply to Filip Pizlo from comment #3)
> (In reply to Myles C. Maxfield from comment #2)
> > Comment on attachment 320407 [details]
> > the patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=320407&action=review
> > 
> > > Tools/WebGPUShadingLanguageRI/Test.js:1439
> > > +            int foo<T>(T) { return 1; }
> > 
> > Why should this fail? I would expect T to become an int.
> 
> I think that's what we should eventually do.  It would take some extra
> effort to implement this.
> 
> Filed: https://bugs.webkit.org/show_bug.cgi?id=176707

If we expect that an idea language wouldn't work this way, we probably shouldn't have this as a test.
Comment 6 Myles C. Maxfield 2017-09-11 11:25:58 PDT
(In reply to Myles C. Maxfield from comment #5)
> (In reply to Filip Pizlo from comment #3)
> > (In reply to Myles C. Maxfield from comment #2)
> > > Comment on attachment 320407 [details]
> > > the patch
> > > 
> > > View in context:
> > > https://bugs.webkit.org/attachment.cgi?id=320407&action=review
> > > 
> > > > Tools/WebGPUShadingLanguageRI/Test.js:1439
> > > > +            int foo<T>(T) { return 1; }
> > > 
> > > Why should this fail? I would expect T to become an int.
> > 
> > I think that's what we should eventually do.  It would take some extra
> > effort to implement this.
> > 
> > Filed: https://bugs.webkit.org/show_bug.cgi?id=176707
> 
> If we expect that an idea language wouldn't work this way, we probably
> shouldn't have this as a test.

**ideal language
Comment 7 Filip Pizlo 2017-09-11 11:33:45 PDT
(In reply to Myles C. Maxfield from comment #6)
> (In reply to Myles C. Maxfield from comment #5)
> > (In reply to Filip Pizlo from comment #3)
> > > (In reply to Myles C. Maxfield from comment #2)
> > > > Comment on attachment 320407 [details]
> > > > the patch
> > > > 
> > > > View in context:
> > > > https://bugs.webkit.org/attachment.cgi?id=320407&action=review
> > > > 
> > > > > Tools/WebGPUShadingLanguageRI/Test.js:1439
> > > > > +            int foo<T>(T) { return 1; }
> > > > 
> > > > Why should this fail? I would expect T to become an int.
> > > 
> > > I think that's what we should eventually do.  It would take some extra
> > > effort to implement this.
> > > 
> > > Filed: https://bugs.webkit.org/show_bug.cgi?id=176707
> > 
> > If we expect that an idea language wouldn't work this way, we probably
> > shouldn't have this as a test.
> 
> **ideal language

More tests are better.  I think it's good practice to add tests for how you expect your code to behave right now, even if that means having to change the test later.

That makes sense here, since the current behavior isn't really "wrong" (it doesn't render the type system unsound or anything like that) - it's just subject to change.
Comment 8 Radar WebKit Bug Importer 2017-09-27 12:33:01 PDT
<rdar://problem/34693466>
Comment 9 Myles C. Maxfield 2018-10-13 16:52:49 PDT
Migrated to https://github.com/gpuweb/WHLSL/issues/145