-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Builtin methods can support array-like arguments #7235
Builtin methods can support array-like arguments #7235
Conversation
build.sbt
Outdated
Test / javacOptions ++= Seq( | ||
"-s", | ||
(Test / sourceManaged).value.getAbsolutePath | ||
), | ||
Compile / logManager := | ||
sbt.internal.util.CustomLogManager.excludeMsg( | ||
"Could not determine source for class ", | ||
Level.Warn | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes spurious errors in IDEA - the *MethodGen
sources are now put into src_managed
rather than on an unknown location inside target
directory.
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Vector.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugly, but it fixes the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Vector.java
Outdated
Show resolved
Hide resolved
Caused by similar design flaw as |
…objects as parameter.
…ing" This reverts commit 4905630.
0d2004d
to
9a9ccf6
Compare
} catch (ClassCastException e) { | ||
throw new PanicException(e, interop); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a Type_Error
also I think, not a ClassCastException
wrapped in panic.
var err = ctx.getBuiltins().error().makeUnsupportedArgumentsError( | ||
new Object[]{arr}, | ||
"Arguments to opts should be host objects from java.io package" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, can this be a Type_Error
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is better as Unsupported_Argument_Types
because it has a message field, as opposed to Type_Error
that only has expected and actual types.
lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/MethodGenerator.java
Show resolved
Hide resolved
return this.truffleFile.newOutputStream(opts); | ||
public OutputStream outputStream(Object opts, | ||
EnsoContext ctx, | ||
@CachedLibrary(limit = "5") InteropLibrary interop) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combination of @TruffleBoundary
and @CachedLibrary
- the usual error...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, my bad. I will fix that in one of my upcoming PRs - ea95a16
Closes #7133.
In
EnsoFile
builtin type, we used to have builtin methods accepting array of some classes fromjava.io
as parameters. That works only if such argument is converted withto_array
. If Vector is passed, it fails.This PR modifies the builtin method processor such that it forbids arrays of non-primitive and non-guest objects in builtin methods. And provides a proper implementation for the builtin methods in
EnsoFile
.Pull Request Description
Builtin methods generator fails for a builtin method that has an array of host objects as parameter:
![image](https://private-user-images.githubusercontent.com/14013887/253217817-8acb7b2b-44f8-4d9d-a5d3-ba97dc02e80e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2NTQxMDQsIm5iZiI6MTcxOTY1MzgwNCwicGF0aCI6Ii8xNDAxMzg4Ny8yNTMyMTc4MTctOGFjYjdiMmItNDRmOC00ZDlkLWE1ZDMtYmE5N2RjMDJlODBlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI5VDA5MzY0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMyYmQ4NmVlMjc4OTlkNGMzYTE0YzFmNmU1YmJjOWNlMjk4NjQyYzAzYmUzYzA1MDBkMzFlNDlmOWYzNzNlYjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Cfqraj11YrAXx6tuQM-T7ahzpLDwOPQe2YJbjJEiYnE)
Important Notes
Vector.to_array
calls fromFile.enso
.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.