Skip to content

Add Extern and Intrinsic body types#1088

Merged
Nadrieril merged 5 commits into
AeneasVerif:mainfrom
soteria-tools:issue-982
Apr 22, 2026
Merged

Add Extern and Intrinsic body types#1088
Nadrieril merged 5 commits into
AeneasVerif:mainfrom
soteria-tools:issue-982

Conversation

@N1ark
Copy link
Copy Markdown
Contributor

@N1ark N1ark commented Apr 6, 2026

Add two variants to Body: Extern(string) and Intrinsic(string)! On the OCaml side, a body isn't just a 'body option anymore: we instead properly translate the Body enum, to give more information to the client.

For now intrinsics are just strings rather than an enum, as I don't have the time to do that part. There is also the question of how we make this enum make sense: some intrinsics actually never get lowered into a function call, and a few of them disappear through the compilation pipeline.

One thing we lose with this change is that we can't get the name of the intrinsic's arguments. This isn't a big deal but in Soteria I generate intrinsic definitions from the ULLBC output, and having names for the arguments is super useful. Maybe we could make a new Argument type that stores a type, optional name (and an ArgAbi?) to keep this information? And then FunSig.inputs would be a Vec<Arg> instead. Let me know.

Fixes #982
First step towards #864

ci: use AeneasVerif/aeneas#919
ci: use AeneasVerif/eurydice#395

@N1ark N1ark force-pushed the issue-982 branch 4 times, most recently from bcde11f to d58443f Compare April 6, 2026 13:33
Copy link
Copy Markdown
Member

@Nadrieril Nadrieril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this, tyvm :)

@Nadrieril
Copy link
Copy Markdown
Member

Re argument names, we can't change FunSig because it's used in TyKind::FnPtr. I'm open to finding a solution though, argument names are useful documentation to preseve.

@N1ark
Copy link
Copy Markdown
Contributor Author

N1ark commented Apr 7, 2026

Re argument names, we can't change FunSig because it's used in TyKind::FnPtr. I'm open to finding a solution though, argument names are useful documentation to preseve.

options:

  1. we could make Arg.name an Option<String>; we don't always have names for locals anyways so it's consistent
  2. FnSig<Meta> with inputs: Vec<(Ty, Meta)> where Meta is either () or String
  3. add a field arg_names: Vec<String> to FunDecl

i think I am happy with either of the three options

@Nadrieril
Copy link
Copy Markdown
Member

Nadrieril commented Apr 7, 2026

How about arg_names: Vec<String> inside Body::Extern and Body::Intrinsic? We could even unify the two variants if useful since they're semantically pretty similar (you tell me what's most useful for you).

@N1ark
Copy link
Copy Markdown
Contributor Author

N1ark commented Apr 7, 2026

i think i prefer both as separate variants just because it makes matching on the enum easier, and i handle both cases separately anyways

yes this sounds good, ill do it now :)

@N1ark N1ark force-pushed the issue-982 branch 2 times, most recently from 79739fe to d7c8d34 Compare April 7, 2026 14:22
@N1ark
Copy link
Copy Markdown
Contributor Author

N1ark commented Apr 17, 2026

This is ready :D @Nadrieril

| Opaque -> Opaque
| Missing -> Missing
| Error err -> Error (self#visit_error env err)
in
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could derive that visitor on body, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm probably, but anyways this will change in #1102 where the visitor won't be possible, so i'd rather leave this as is

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

Comment thread charon-ml/src/Substitute.ml Outdated
Comment thread charon/src/ast/gast.rs Outdated
@Nadrieril Nadrieril added this pull request to the merge queue Apr 22, 2026
Merged via the queue into AeneasVerif:main with commit dddac02 Apr 22, 2026
5 checks passed
@N1ark
Copy link
Copy Markdown
Contributor Author

N1ark commented Apr 26, 2026

Re argument names, we can't change FunSig because it's used in TyKind::FnPtr. I'm open to finding a solution though, argument names are useful documentation to preseve.

maybe that could change ?
rust-lang/rfcs#3955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: extern function names

2 participants